summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/chat-commands.c8
-rw-r--r--src/core/chat-protocols.c3
-rw-r--r--src/core/chat-protocols.h2
-rw-r--r--src/fe-common/core/fe-common-core.c108
-rw-r--r--src/fe-common/core/fe-server.c12
-rw-r--r--src/fe-common/core/module-formats.c1
-rw-r--r--src/fe-common/core/module-formats.h1
-rw-r--r--src/fe-common/irc/fe-common-irc.c76
-rw-r--r--src/fe-common/irc/fe-common-irc.h1
-rw-r--r--src/fe-text/irssi.c1
10 files changed, 122 insertions, 91 deletions
diff --git a/src/core/chat-commands.c b/src/core/chat-commands.c
index a22e24d2..5e0be456 100644
--- a/src/core/chat-commands.c
+++ b/src/core/chat-commands.c
@@ -66,6 +66,14 @@ static SERVER_CONNECT_REC *get_server_connect(const char *data, int *plus_addr)
if (proto == NULL)
proto = chat_protocol_find_id(conn->chat_type);
+ if (proto->not_initialized) {
+ /* trying to use protocol that isn't yet initialized */
+ signal_emit("chat protocol unknown", 1, proto->name);
+ server_connect_free(conn);
+ cmd_params_free(free_arg);
+ return NULL;
+ }
+
if (g_hash_table_lookup(optlist, "6") != NULL)
conn->family = AF_INET6;
else if (g_hash_table_lookup(optlist, "4") != NULL)
diff --git a/src/core/chat-protocols.c b/src/core/chat-protocols.c
index 88199656..ab7c09d4 100644
--- a/src/core/chat-protocols.c
+++ b/src/core/chat-protocols.c
@@ -202,7 +202,8 @@ CHAT_PROTOCOL_REC *chat_protocol_get_unknown(const char *name)
if (rec != NULL)
return rec;
- rec = g_new0(CHAT_PROTOCOL_REC, 1);
+ rec = g_new0(CHAT_PROTOCOL_REC, 1);
+ rec->not_initialized = TRUE;
rec->name = (char *) name;
rec->create_chatnet = create_chatnet;
rec->create_server_setup = create_server_setup;
diff --git a/src/core/chat-protocols.h b/src/core/chat-protocols.h
index a8467333..cc7eaadc 100644
--- a/src/core/chat-protocols.h
+++ b/src/core/chat-protocols.h
@@ -4,6 +4,8 @@
typedef struct {
int id;
+ unsigned int not_initialized:1;
+
char *name;
char *fullname;
char *chatnet;
diff --git a/src/fe-common/core/fe-common-core.c b/src/fe-common/core/fe-common-core.c
index 38de0d65..a48d1a4e 100644
--- a/src/fe-common/core/fe-common-core.c
+++ b/src/fe-common/core/fe-common-core.c
@@ -20,9 +20,13 @@
#include "module.h"
#include "module-formats.h"
+#include "args.h"
+#include "misc.h"
#include "levels.h"
#include "settings.h"
+
#include "channels.h"
+#include "servers-setup.h"
#include "fe-queries.h"
#include "hilight-text.h"
@@ -40,6 +44,13 @@
#include <signal.h>
+static char *autocon_server;
+static char *autocon_password;
+static int autocon_port;
+static int no_autoconnect;
+static char *cmdline_nick;
+static char *cmdline_hostname;
+
void autorun_init(void);
void autorun_deinit(void);
@@ -104,6 +115,24 @@ static void sig_channel_destroyed(CHANNEL_REC *channel)
void fe_common_core_init(void)
{
+ static struct poptOption options[] = {
+ { "connect", 'c', POPT_ARG_STRING, &autocon_server, 0, N_("Automatically connect to server/ircnet"), N_("SERVER") },
+ { "password", 'w', POPT_ARG_STRING, &autocon_password, 0, N_("Autoconnect password"), N_("SERVER") },
+ { "port", 'p', POPT_ARG_INT, &autocon_port, 0, N_("Autoconnect port"), N_("PORT") },
+ { "noconnect", '!', POPT_ARG_NONE, &no_autoconnect, 0, N_("Disable autoconnecting"), NULL },
+ { "nick", 'n', POPT_ARG_STRING, &cmdline_nick, 0, N_("Specify nick to use"), NULL },
+ { "hostname", 'h', POPT_ARG_STRING, &cmdline_hostname, 0, N_("Specify host name to use"), NULL },
+ { NULL, '\0', 0, NULL }
+ };
+
+ autocon_server = NULL;
+ autocon_password = NULL;
+ autocon_port = 6667;
+ no_autoconnect = FALSE;
+ cmdline_nick = NULL;
+ cmdline_hostname = NULL;
+ args_register(options);
+
settings_add_bool("lookandfeel", "timestamps", TRUE);
settings_add_bool("lookandfeel", "msgs_timestamps", FALSE);
settings_add_bool("lookandfeel", "hide_text_style", FALSE);
@@ -220,21 +249,10 @@ void glog_func(const char *log_domain, GLogLevelFlags log_level,
}
}
-void fe_common_core_finish_init(void)
+static void create_windows(void)
{
WINDOW_REC *window;
- g_log_set_handler(G_LOG_DOMAIN,
- (GLogLevelFlags) (G_LOG_LEVEL_CRITICAL |
- G_LOG_LEVEL_WARNING),
- (GLogFunc) glog_func, NULL);
-
- signal_emit("irssi init read settings", 0);
-
-#ifdef SIGPIPE
- signal(SIGPIPE, SIG_IGN);
-#endif
-
windows_restore();
if (windows != NULL)
return;
@@ -258,3 +276,69 @@ void fe_common_core_finish_init(void)
window = window_create(NULL, TRUE);
}
}
+
+static void autoconnect_servers(void)
+{
+ GSList *tmp, *chatnets;
+ char *str;
+
+ if (autocon_server != NULL) {
+ /* connect to specified server */
+ str = g_strdup_printf(autocon_password == NULL ? "%s %d" : "%s %d %s",
+ autocon_server, autocon_port, autocon_password);
+ signal_emit("command connect", 1, str);
+ g_free(str);
+ return;
+ }
+
+ if (no_autoconnect) {
+ /* don't autoconnect */
+ return;
+ }
+
+ /* connect to autoconnect servers */
+ chatnets = NULL;
+ for (tmp = setupservers; tmp != NULL; tmp = tmp->next) {
+ SERVER_SETUP_REC *rec = tmp->data;
+
+ if (rec->autoconnect &&
+ (rec->chatnet == NULL ||
+ gslist_find_icase_string(chatnets, rec->chatnet) == NULL)) {
+ if (rec->chatnet != NULL)
+ chatnets = g_slist_append(chatnets, rec->chatnet);
+
+ str = g_strdup_printf("%s %d", rec->address, rec->port);
+ signal_emit("command connect", 1, str);
+ g_free(str);
+ }
+ }
+
+ g_slist_free(chatnets);
+}
+
+void fe_common_core_finish_init(void)
+{
+ g_log_set_handler(G_LOG_DOMAIN,
+ (GLogLevelFlags) (G_LOG_LEVEL_CRITICAL |
+ G_LOG_LEVEL_WARNING),
+ (GLogFunc) glog_func, NULL);
+
+ signal_emit("irssi init read settings", 0);
+
+#ifdef SIGPIPE
+ signal(SIGPIPE, SIG_IGN);
+#endif
+
+ if (cmdline_nick != NULL) {
+ /* override nick found from setup */
+ settings_set_str("nick", cmdline_nick);
+ }
+
+ if (cmdline_hostname != NULL) {
+ /* override host name found from setup */
+ settings_set_str("hostname", cmdline_hostname);
+ }
+
+ create_windows();
+ autoconnect_servers();
+}
diff --git a/src/fe-common/core/fe-server.c b/src/fe-common/core/fe-server.c
index d96dcfe1..a1c07db0 100644
--- a/src/fe-common/core/fe-server.c
+++ b/src/fe-common/core/fe-server.c
@@ -302,6 +302,14 @@ static void sig_server_reconnect_not_found(const char *tag)
TXT_RECONNECT_NOT_FOUND, tag);
}
+static void sig_chat_protocol_unknown(const char *protocol)
+{
+ g_return_if_fail(protocol != NULL);
+
+ printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
+ TXT_UNKNOWN_CHAT_PROTOCOL, protocol);
+}
+
void fe_server_init(void)
{
command_bind("server", NULL, (SIGNAL_FUNC) cmd_server);
@@ -319,6 +327,8 @@ void fe_server_init(void)
signal_add("server lag disconnect", (SIGNAL_FUNC) sig_server_lag_disconnected);
signal_add("server reconnect remove", (SIGNAL_FUNC) sig_server_reconnect_removed);
signal_add("server reconnect not found", (SIGNAL_FUNC) sig_server_reconnect_not_found);
+
+ signal_add("chat protocol unknown", (SIGNAL_FUNC) sig_chat_protocol_unknown);
}
void fe_server_deinit(void)
@@ -337,4 +347,6 @@ void fe_server_deinit(void)
signal_remove("server lag disconnect", (SIGNAL_FUNC) sig_server_lag_disconnected);
signal_remove("server reconnect remove", (SIGNAL_FUNC) sig_server_reconnect_removed);
signal_remove("server reconnect not found", (SIGNAL_FUNC) sig_server_reconnect_not_found);
+
+ signal_remove("chat protocol unknown", (SIGNAL_FUNC) sig_chat_protocol_unknown);
}
diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c
index 9694b541..f09054c3 100644
--- a/src/fe-common/core/module-formats.c
+++ b/src/fe-common/core/module-formats.c
@@ -207,6 +207,7 @@ FORMAT_REC fecommon_core_formats[] = {
/* ---- */
{ NULL, "Misc", 0 },
+ { "unknown_chat_protocol", "Unknown chat protocol: $0", 1, { 0 } },
{ "unknown_chatnet", "Unknown chat network: $0", 1, { 0 } },
{ "not_toggle", "Value must be either ON, OFF or TOGGLE", 0 },
{ "perl_error", "Perl error: $0", 1, { 0 } },
diff --git a/src/fe-common/core/module-formats.h b/src/fe-common/core/module-formats.h
index 3126ba54..c41ca316 100644
--- a/src/fe-common/core/module-formats.h
+++ b/src/fe-common/core/module-formats.h
@@ -173,6 +173,7 @@ enum {
TXT_FILL_13,
+ TXT_UNKNOWN_CHAT_PROTOCOL,
TXT_UNKNOWN_CHATNET,
TXT_NOT_TOGGLE,
TXT_PERL_ERROR,
diff --git a/src/fe-common/irc/fe-common-irc.c b/src/fe-common/irc/fe-common-irc.c
index a0169299..aed6afac 100644
--- a/src/fe-common/irc/fe-common-irc.c
+++ b/src/fe-common/irc/fe-common-irc.c
@@ -21,13 +21,10 @@
#include "module.h"
#include "module-formats.h"
#include "signals.h"
-#include "args.h"
#include "misc.h"
#include "lib-config/iconfig.h"
#include "settings.h"
-#include "servers-setup.h"
-
#include "themes.h"
void fe_irc_modules_init(void);
@@ -69,33 +66,8 @@ void fe_netsplit_deinit(void);
void fe_netjoin_init(void);
void fe_netjoin_deinit(void);
-static char *autocon_server;
-static char *autocon_password;
-static int autocon_port;
-static int no_autoconnect;
-static char *cmdline_nick;
-static char *cmdline_hostname;
-
void fe_common_irc_init(void)
{
- static struct poptOption options[] = {
- { "connect", 'c', POPT_ARG_STRING, &autocon_server, 0, N_("Automatically connect to server/ircnet"), N_("SERVER") },
- { "password", 'w', POPT_ARG_STRING, &autocon_password, 0, N_("Autoconnect password"), N_("SERVER") },
- { "port", 'p', POPT_ARG_INT, &autocon_port, 0, N_("Autoconnect port"), N_("PORT") },
- { "noconnect", '!', POPT_ARG_NONE, &no_autoconnect, 0, N_("Disable autoconnecting"), NULL },
- { "nick", 'n', POPT_ARG_STRING, &cmdline_nick, 0, N_("Specify nick to use"), NULL },
- { "hostname", 'h', POPT_ARG_STRING, &cmdline_hostname, 0, N_("Specify host name to use"), NULL },
- { NULL, '\0', 0, NULL }
- };
-
- autocon_server = NULL;
- autocon_password = NULL;
- autocon_port = 6667;
- no_autoconnect = FALSE;
- cmdline_nick = NULL;
- cmdline_hostname = NULL;
- args_register(options);
-
settings_add_bool("lookandfeel", "show_away_once", TRUE);
theme_register(fecommon_irc_formats);
@@ -136,51 +108,3 @@ void fe_common_irc_deinit(void)
theme_unregister();
}
-
-void fe_common_irc_finish_init(void)
-{
- GSList *tmp, *ircnets;
- char *str;
-
- if (cmdline_nick != NULL) {
- /* override nick found from setup */
- settings_set_str("nick", cmdline_nick);
- }
-
- if (cmdline_hostname != NULL) {
- /* override host name found from setup */
- settings_set_str("hostname", cmdline_hostname);
- }
-
- if (autocon_server != NULL) {
- /* connect to specified server */
- str = g_strdup_printf(autocon_password == NULL ? "%s %d" : "%s %d %s",
- autocon_server, autocon_port, autocon_password);
- signal_emit("command connect", 1, str);
- g_free(str);
- return;
- }
-
- if (no_autoconnect) {
- /* don't autoconnect */
- return;
- }
-
- /* connect to autoconnect servers */
- ircnets = NULL;
- for (tmp = setupservers; tmp != NULL; tmp = tmp->next) {
- SERVER_SETUP_REC *rec = tmp->data;
-
- if (rec->autoconnect && (rec->chatnet == NULL || *rec->chatnet == '\0' ||
- gslist_find_icase_string(ircnets, rec->chatnet) == NULL)) {
- if (rec->chatnet != NULL && *rec->chatnet != '\0')
- ircnets = g_slist_append(ircnets, rec->chatnet);
-
- str = g_strdup_printf("%s %d", rec->address, rec->port);
- signal_emit("command connect", 1, str);
- g_free(str);
- }
- }
-
- g_slist_free(ircnets);
-}
diff --git a/src/fe-common/irc/fe-common-irc.h b/src/fe-common/irc/fe-common-irc.h
index 0ad3a564..5d65a3bb 100644
--- a/src/fe-common/irc/fe-common-irc.h
+++ b/src/fe-common/irc/fe-common-irc.h
@@ -3,6 +3,5 @@
void fe_common_irc_init(void);
void fe_common_irc_deinit(void);
-void fe_common_irc_finish_init(void);
#endif
diff --git a/src/fe-text/irssi.c b/src/fe-text/irssi.c
index e9a484ae..2bbc2e76 100644
--- a/src/fe-text/irssi.c
+++ b/src/fe-text/irssi.c
@@ -135,7 +135,6 @@ static void textui_finish_init(void)
settings_check();
fe_common_core_finish_init();
- fe_common_irc_finish_init();
#ifdef HAVE_STATIC_PERL
perl_core_init();