summaryrefslogtreecommitdiff
path: root/src/irc/core
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-09-02 18:53:58 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-09-02 18:53:58 +0000
commit755a8d40eb5f9e0a12b98e4f84332891a3d63b1a (patch)
treeb96a317a11affdb428a121176836cf48e707c286 /src/irc/core
parent28a7908e7372fe0e81dd439b6559bc2abe3ea6e8 (diff)
downloadirssi-755a8d40eb5f9e0a12b98e4f84332891a3d63b1a.zip
Updates.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@641 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc/core')
-rw-r--r--src/irc/core/Makefile.am1
-rw-r--r--src/irc/core/irc-channels.c18
-rw-r--r--src/irc/core/irc-commands.c44
-rw-r--r--src/irc/core/irc-commands.h10
-rw-r--r--src/irc/core/irc-queries.c17
5 files changed, 38 insertions, 52 deletions
diff --git a/src/irc/core/Makefile.am b/src/irc/core/Makefile.am
index c0b8075c..99f72229 100644
--- a/src/irc/core/Makefile.am
+++ b/src/irc/core/Makefile.am
@@ -41,7 +41,6 @@ noinst_HEADERS = \
irc.h \
irc-channels.h \
irc-chatnets.h \
- irc-commands.h \
irc-masks.h \
irc-nicklist.h \
irc-queries.h \
diff --git a/src/irc/core/irc-channels.c b/src/irc/core/irc-channels.c
index eb63a865..7786199a 100644
--- a/src/irc/core/irc-channels.c
+++ b/src/irc/core/irc-channels.c
@@ -61,6 +61,22 @@ IRC_CHANNEL_REC *irc_channel_create(IRC_SERVER_REC *server,
return rec;
}
+static void sig_channel_create(IRC_CHANNEL_REC **channel,
+ void *chat_type, IRC_SERVER_REC *server,
+ const char *name, void *automatic)
+{
+ if (chat_protocol_lookup("IRC") != GPOINTER_TO_INT(chat_type))
+ return;
+
+ g_return_if_fail(server == NULL || IS_IRC_SERVER(server));
+ g_return_if_fail(channel != NULL);
+ g_return_if_fail(name != NULL);
+
+ *channel = irc_channel_create(server, name,
+ GPOINTER_TO_INT(automatic));
+ signal_stop();
+}
+
static void sig_channel_destroyed(IRC_CHANNEL_REC *channel)
{
if (!IS_IRC_CHANNEL(channel))
@@ -179,6 +195,7 @@ static void sig_connected(SERVER_REC *server)
void irc_channels_init(void)
{
+ signal_add("channel create", (SIGNAL_FUNC) sig_channel_create);
signal_add("server connected", (SIGNAL_FUNC) sig_connected);
signal_add("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
@@ -196,6 +213,7 @@ void irc_channels_init(void)
void irc_channels_deinit(void)
{
+ signal_remove("channel create", (SIGNAL_FUNC) sig_channel_create);
signal_remove("server connected", (SIGNAL_FUNC) sig_connected);
signal_remove("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
diff --git a/src/irc/core/irc-commands.c b/src/irc/core/irc-commands.c
index c5d91ef6..c6773712 100644
--- a/src/irc/core/irc-commands.c
+++ b/src/irc/core/irc-commands.c
@@ -26,9 +26,9 @@
#include "settings.h"
#include "window-item-def.h"
-#include "nicklist.h"
#include "servers-redirect.h"
#include "servers-setup.h"
+#include "nicklist.h"
#include "bans.h"
#include "irc.h"
@@ -48,44 +48,6 @@ typedef struct {
static GString *tmpstr;
static int knockout_tag;
-/* `optlist' should contain only one key - the server tag.
- returns NULL if there was unknown -option */
-IRC_SERVER_REC *irccmd_options_get_server(const char *cmd,
- GHashTable *optlist,
- IRC_SERVER_REC *defserver)
-{
- SERVER_REC *server;
- GSList *list, *tmp, *next;
-
- /* get all the options, then remove the known ones. there should
- be only one left - the server tag. */
- list = hashtable_get_keys(optlist);
- for (tmp = list; tmp != NULL; tmp = next) {
- char *option = tmp->data;
- next = tmp->next;
-
- if (command_have_option(cmd, option))
- list = g_slist_remove(list, option);
- }
-
- if (list == NULL)
- return defserver;
-
- server = server_find_tag(list->data);
- if (server == NULL || list->next != NULL) {
- /* unknown option (not server tag) */
- signal_emit("error command", 2,
- GINT_TO_POINTER(CMDERR_OPTION_UNKNOWN),
- server == NULL ? list->data : list->next->data);
- signal_stop();
-
- server = NULL;
- }
-
- g_slist_free(list);
- return (IRC_SERVER_REC *) server;
-}
-
static SERVER_REC *irc_connect_server(const char *data)
{
SERVER_CONNECT_REC *conn;
@@ -259,7 +221,7 @@ static void cmd_msg(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
return;
if (*target == '\0' || *msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
- server = irccmd_options_get_server("msg", optlist, server);
+ server = IRC_SERVER(cmd_options_get_server("msg", optlist, SERVER(server)));
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_param_error(CMDERR_NOT_CONNECTED);
@@ -364,7 +326,7 @@ static void cmd_join(const char *data, IRC_SERVER_REC *server)
irc_channels_join(server, server->last_invite, FALSE);
} else {
/* -<server tag> */
- server = irccmd_options_get_server("join", optlist, server);
+ server = IRC_SERVER(cmd_options_get_server("join", optlist, SERVER(server)));
if (server != NULL) irc_channels_join(server, channels, FALSE);
}
diff --git a/src/irc/core/irc-commands.h b/src/irc/core/irc-commands.h
deleted file mode 100644
index 900a7765..00000000
--- a/src/irc/core/irc-commands.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __IRC_COMMANDS_H
-#define __IRC_COMMANDS_H
-
-/* `optlist' should contain only one key - the server tag.
- returns NULL if there was unknown -option */
-IRC_SERVER_REC *irccmd_options_get_server(const char *cmd,
- GHashTable *optlist,
- IRC_SERVER_REC *defserver);
-
-#endif
diff --git a/src/irc/core/irc-queries.c b/src/irc/core/irc-queries.c
index d2dfee1c..6d16a030 100644
--- a/src/irc/core/irc-queries.c
+++ b/src/irc/core/irc-queries.c
@@ -41,6 +41,21 @@ QUERY_REC *irc_query_create(IRC_SERVER_REC *server,
return rec;
}
+static void sig_query_create(QUERY_REC **query,
+ void *chat_type, IRC_SERVER_REC *server,
+ const char *nick, void *automatic)
+{
+ if (chat_protocol_lookup("IRC") != GPOINTER_TO_INT(chat_type))
+ return;
+
+ g_return_if_fail(server == NULL || IS_IRC_SERVER(server));
+ g_return_if_fail(query != NULL);
+ g_return_if_fail(nick != NULL);
+
+ *query = irc_query_create(server, nick, GPOINTER_TO_INT(automatic));
+ signal_stop();
+}
+
static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *nick, const char *addr)
{
char *params, *target, *msg;
@@ -86,12 +101,14 @@ static void event_nick(const char *data, IRC_SERVER_REC *server, const char *ori
void irc_queries_init(void)
{
+ signal_add("query create", (SIGNAL_FUNC) sig_query_create);
signal_add_last("event privmsg", (SIGNAL_FUNC) event_privmsg);
signal_add("event nick", (SIGNAL_FUNC) event_nick);
}
void irc_queries_deinit(void)
{
+ signal_remove("query create", (SIGNAL_FUNC) sig_query_create);
signal_remove("event privmsg", (SIGNAL_FUNC) event_privmsg);
signal_remove("event nick", (SIGNAL_FUNC) event_nick);
}