From 308e84bbc44db92fbb1fe0c2e177ae981865b788 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 12 Aug 2000 02:16:52 +0000 Subject: WJOIN -> /JOIN -window WQUERY -> /QUERY -window. Added support for /QUERY -. Added aliases for WJOIN and WQUERY to default config file. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@590 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-common/irc/fe-channels.c | 44 +++++++++++++++++++++++++++++++----- src/fe-common/irc/fe-irc-commands.c | 29 ++++++++++++++++++------ src/fe-common/irc/fe-query.c | 45 ++++++++++++++++++++++++++++++++----- src/fe-common/irc/irc-completion.c | 2 +- 4 files changed, 100 insertions(+), 20 deletions(-) (limited to 'src/fe-common') diff --git a/src/fe-common/irc/fe-channels.c b/src/fe-common/irc/fe-channels.c index 64b07fa7..4c1a7011 100644 --- a/src/fe-common/irc/fe-channels.c +++ b/src/fe-common/irc/fe-channels.c @@ -108,11 +108,40 @@ static void signal_window_item_changed(WINDOW_REC *window, WI_ITEM_REC *item) } } -static void cmd_wjoin(const char *data, void *server, WI_ITEM_REC *item) +static void cmd_wjoin_pre(const char *data) { - signal_add("channel created", (SIGNAL_FUNC) signal_channel_created_curwin); - signal_emit("command join", 3, data, server, item); - signal_remove("channel created", (SIGNAL_FUNC) signal_channel_created_curwin); + GHashTable *optlist; + char *nick; + void *free_arg; + + if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | + PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST, + "join", &optlist, &nick)) + return; + + if (g_hash_table_lookup(optlist, "window") != NULL) { + signal_add("channel created", + (SIGNAL_FUNC) signal_channel_created_curwin); + } + cmd_params_free(free_arg); +} + +static void cmd_wjoin_post(const char *data) +{ + GHashTable *optlist; + char *nick; + void *free_arg; + + if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | + PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST, + "join", &optlist, &nick)) + return; + + if (g_hash_table_lookup(optlist, "window") != NULL) { + signal_remove("channel created", + (SIGNAL_FUNC) signal_channel_created_curwin); + } + cmd_params_free(free_arg); } static void cmd_channel_list_joined(void) @@ -265,13 +294,15 @@ void fe_channels_init(void) signal_add_last("window item changed", (SIGNAL_FUNC) signal_window_item_changed); signal_add_last("server disconnected", (SIGNAL_FUNC) sig_disconnected); - command_bind("wjoin", NULL, (SIGNAL_FUNC) cmd_wjoin); + command_bind_first("join", NULL, (SIGNAL_FUNC) cmd_wjoin_pre); + command_bind_last("join", NULL, (SIGNAL_FUNC) cmd_wjoin_post); command_bind("channel", NULL, (SIGNAL_FUNC) cmd_channel); command_bind("channel add", NULL, (SIGNAL_FUNC) cmd_channel_add); command_bind("channel remove", NULL, (SIGNAL_FUNC) cmd_channel_remove); command_bind("channel list", NULL, (SIGNAL_FUNC) cmd_channel_list); command_set_options("channel add", "auto noauto -bots -botcmd"); + command_set_options("join", "window"); } void fe_channels_deinit(void) @@ -282,7 +313,8 @@ void fe_channels_deinit(void) signal_remove("window item changed", (SIGNAL_FUNC) signal_window_item_changed); signal_remove("server disconnected", (SIGNAL_FUNC) sig_disconnected); - command_unbind("wjoin", (SIGNAL_FUNC) cmd_wjoin); + command_unbind("join", (SIGNAL_FUNC) cmd_wjoin_pre); + command_unbind("join", (SIGNAL_FUNC) cmd_wjoin_post); command_unbind("channel", (SIGNAL_FUNC) cmd_channel); command_unbind("channel add", (SIGNAL_FUNC) cmd_channel_add); command_unbind("channel remove", (SIGNAL_FUNC) cmd_channel_remove); diff --git a/src/fe-common/irc/fe-irc-commands.c b/src/fe-common/irc/fe-irc-commands.c index d539ac70..260acbba 100644 --- a/src/fe-common/irc/fe-irc-commands.c +++ b/src/fe-common/irc/fe-irc-commands.c @@ -63,8 +63,11 @@ static void cmd_unquery(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *it /* SYNTAX: QUERY */ static void cmd_query(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item) { + GHashTable *optlist; WINDOW_REC *window; QUERY_REC *query; + char *nick; + void *free_arg; g_return_if_fail(data != NULL); @@ -74,21 +77,33 @@ static void cmd_query(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item return; } - if (*data != '=' && (server == NULL || !server->connected)) - cmd_return_error(CMDERR_NOT_CONNECTED); + if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | + PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST, + "query", &optlist, &nick)) + return; + if (*nick == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); + server = irccmd_options_get_server("query", optlist, server); + if (server == NULL) { + cmd_params_free(free_arg); + return; + } + + if (*nick != '=' && (server == NULL || !server->connected)) + cmd_param_error(CMDERR_NOT_CONNECTED); - query = query_find(server, data); - if (query != NULL) { + query = query_find(server, nick); + if (query == NULL) + query_create(server, nick, FALSE); + else { /* query already existed - change to query window */ window = window_item_window((WI_ITEM_REC *) query); g_return_if_fail(window != NULL); window_set_active(window); window_item_set_active(window, (WI_ITEM_REC *) query); - return; } - query_create(server, data, FALSE); + cmd_params_free(free_arg); } static void cmd_msg(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item) @@ -109,7 +124,7 @@ static void cmd_msg(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item) "msg", &optlist, &target, &msg)) return; if (*target == '\0' || *msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - server = irccmd_options_get_server(optlist, server); + server = irccmd_options_get_server("msg", optlist, server); if (*target == '=') { diff --git a/src/fe-common/irc/fe-query.c b/src/fe-common/irc/fe-query.c index ee1505bd..6fe9bf64 100644 --- a/src/fe-common/irc/fe-query.c +++ b/src/fe-common/irc/fe-query.c @@ -129,11 +129,40 @@ static void cmd_window_server(const char *data) } } -static void cmd_wquery(const char *data, void *server, WI_ITEM_REC *item) +static void cmd_wquery_pre(const char *data) { - signal_add("query created", (SIGNAL_FUNC) signal_query_created_curwin); - signal_emit("command query", 3, data, server, item); - signal_remove("query created", (SIGNAL_FUNC) signal_query_created_curwin); + GHashTable *optlist; + char *nick; + void *free_arg; + + if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | + PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST, + "query", &optlist, &nick)) + return; + + if (g_hash_table_lookup(optlist, "window") != NULL) { + signal_add("query created", + (SIGNAL_FUNC) signal_query_created_curwin); + } + cmd_params_free(free_arg); +} + +static void cmd_wquery_post(const char *data) +{ + GHashTable *optlist; + char *nick; + void *free_arg; + + if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | + PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST, + "query", &optlist, &nick)) + return; + + if (g_hash_table_lookup(optlist, "window") != NULL) { + signal_remove("query created", + (SIGNAL_FUNC) signal_query_created_curwin); + } + cmd_params_free(free_arg); } static int window_has_query(WINDOW_REC *window) @@ -210,8 +239,11 @@ void fe_query_init(void) signal_add("window changed", (SIGNAL_FUNC) sig_window_changed); signal_add("setup changed", (SIGNAL_FUNC) read_settings); - command_bind("wquery", NULL, (SIGNAL_FUNC) cmd_wquery); + command_bind_first("query", NULL, (SIGNAL_FUNC) cmd_wquery_pre); + command_bind_last("query", NULL, (SIGNAL_FUNC) cmd_wquery_post); command_bind("window server", NULL, (SIGNAL_FUNC) cmd_window_server); + + command_set_options("query", "window"); } void fe_query_deinit(void) @@ -225,6 +257,7 @@ void fe_query_deinit(void) signal_remove("window changed", (SIGNAL_FUNC) sig_window_changed); signal_remove("setup changed", (SIGNAL_FUNC) read_settings); - command_unbind("wquery", (SIGNAL_FUNC) cmd_wquery); + command_unbind("query", (SIGNAL_FUNC) cmd_wquery_pre); + command_unbind("query", (SIGNAL_FUNC) cmd_wquery_post); command_unbind("window server", (SIGNAL_FUNC) cmd_window_server); } diff --git a/src/fe-common/irc/irc-completion.c b/src/fe-common/irc/irc-completion.c index 5de5294d..91e7fecf 100644 --- a/src/fe-common/irc/irc-completion.c +++ b/src/fe-common/irc/irc-completion.c @@ -259,7 +259,7 @@ static void cmd_msg(const char *data, IRC_SERVER_REC *server) PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST, "msg", &optlist, &target, &msg)) return; - server = irccmd_options_get_server(optlist, server); + server = irccmd_options_get_server("msg", optlist, server); if (*target != '\0' && *msg != '\0') { if (!ischannel(*target) && *target != '=' && server != NULL) -- cgit v1.2.3