summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-09-01 00:26:46 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-09-01 00:26:46 +0000
commit28a7908e7372fe0e81dd439b6559bc2abe3ea6e8 (patch)
treef911b89cd7d5a5f5e9fb206c380cd5ddebe1b987
parent03091413eeb0935adfad1bee7b02a0161f403835 (diff)
downloadirssi-28a7908e7372fe0e81dd439b6559bc2abe3ea6e8.zip
Added chat protocol register. Changed all chat_type fields to use it.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@640 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r--src/core/Makefile.am2
-rw-r--r--src/core/channels.c3
-rw-r--r--src/core/chat-protocols.c172
-rw-r--r--src/core/chat-protocols.h29
-rw-r--r--src/core/chatnet-rec.h4
-rw-r--r--src/core/core.c3
-rw-r--r--src/core/queries.c2
-rw-r--r--src/core/server-connect-rec.h4
-rw-r--r--src/core/server-rec.h7
-rw-r--r--src/core/server-setup-rec.h4
-rw-r--r--src/core/window-item-rec.h4
-rw-r--r--src/fe-text/statusbar-items.c16
-rw-r--r--src/irc/core/irc-channels.c7
-rw-r--r--src/irc/core/irc-channels.h3
-rw-r--r--src/irc/core/irc-chatnets.c6
-rw-r--r--src/irc/core/irc-chatnets.h5
-rw-r--r--src/irc/core/irc-core.c5
-rw-r--r--src/irc/core/irc-queries.c14
-rw-r--r--src/irc/core/irc-queries.h3
-rw-r--r--src/irc/core/irc-servers-reconnect.c2
-rw-r--r--src/irc/core/irc-servers-setup.c6
-rw-r--r--src/irc/core/irc-servers-setup.h6
-rw-r--r--src/irc/core/irc-servers.c4
-rw-r--r--src/irc/core/irc-servers.h7
-rw-r--r--src/irc/core/irc.c2
-rw-r--r--src/irc/core/module.h1
26 files changed, 259 insertions, 62 deletions
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index d7534ee5..d6dd6e84 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -18,6 +18,7 @@ libcore_a_SOURCES = \
channels.c \
channels-setup.c \
commands.c \
+ chat-protocols.c \
chatnets.c \
core.c \
levels.c \
@@ -57,6 +58,7 @@ noinst_HEADERS = \
channels.h \
channels-setup.h \
commands.h \
+ chat-protocols.h \
chatnets.h \
core.h \
levels.h \
diff --git a/src/core/channels.c b/src/core/channels.c
index bc3d8c0b..0cbcfa55 100644
--- a/src/core/channels.c
+++ b/src/core/channels.c
@@ -62,6 +62,7 @@ void channel_destroy(CHANNEL_REC *channel)
MODULE_DATA_DEINIT(channel);
g_free_not_null(channel->topic);
g_free_not_null(channel->key);
+ g_free(channel->mode);
g_free(channel->name);
g_free(channel);
}
@@ -84,7 +85,7 @@ static CHANNEL_REC *channel_find_server(SERVER_REC *server,
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
CHANNEL_REC *rec = tmp->data;
- if (rec->chat_type == server->channel_type &&
+ if (rec->chat_type == server->chat_type &&
g_strcasecmp(name, rec->name) == 0)
return rec;
}
diff --git a/src/core/chat-protocols.c b/src/core/chat-protocols.c
new file mode 100644
index 00000000..a5537f88
--- /dev/null
+++ b/src/core/chat-protocols.c
@@ -0,0 +1,172 @@
+/*
+ chat-protocol.c : irssi
+
+ Copyright (C) 2000 Timo Sirainen
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "module.h"
+#include "chat-protocols.h"
+
+typedef struct {
+ int id;
+ char *name;
+ char *fullname;
+ char *chatnet;
+} PROTOCOL_REC;
+
+static int id_counter;
+static GSList *protocols;
+
+void *chat_protocol_check_cast(void *object, int type_pos, const char *id)
+{
+ return object == NULL ||
+ chat_protocol_lookup(id) !=
+ G_STRUCT_MEMBER(int, object, type_pos) ? NULL : object;
+}
+
+static PROTOCOL_REC *chat_protocol_find(const char *name)
+{
+ GSList *tmp;
+
+ g_return_val_if_fail(name != NULL, NULL);
+
+ for (tmp = protocols; tmp != NULL; tmp = tmp->next) {
+ PROTOCOL_REC *rec = tmp->data;
+
+ if (g_strcasecmp(rec->name, name) == 0)
+ return rec;
+ }
+
+ return NULL;
+}
+
+static PROTOCOL_REC *chat_protocol_find_id(int id)
+{
+ GSList *tmp;
+
+ g_return_val_if_fail(id > 0, NULL);
+
+ for (tmp = protocols; tmp != NULL; tmp = tmp->next) {
+ PROTOCOL_REC *rec = tmp->data;
+
+ if (rec->id == id)
+ return rec;
+ }
+
+ return NULL;
+}
+
+/* Register new chat protocol. */
+void chat_protocol_register(const char *name,
+ const char *fullname,
+ const char *chatnet)
+{
+ PROTOCOL_REC *rec;
+
+ g_return_if_fail(name != NULL);
+ g_return_if_fail(fullname != NULL);
+ g_return_if_fail(chatnet != NULL);
+
+ if (chat_protocol_find(name) != NULL)
+ return;
+
+ rec = g_new0(PROTOCOL_REC, 1);
+ rec->id = ++id_counter;
+ rec->name = g_strdup(name);
+ rec->fullname = g_strdup(fullname);
+ rec->chatnet = g_strdup(chatnet);
+ protocols = g_slist_append(protocols, rec);
+}
+
+static void chat_protocol_destroy(PROTOCOL_REC *rec)
+{
+ g_return_if_fail(rec != NULL);
+
+ protocols = g_slist_remove(protocols, rec);
+
+ g_free(rec->name);
+ g_free(rec->fullname);
+ g_free(rec->chatnet);
+ g_free(rec);
+}
+
+/* Unregister chat protocol. */
+void chat_protocol_unregister(const char *name)
+{
+ PROTOCOL_REC *rec;
+
+ g_return_if_fail(name != NULL);
+
+ rec = chat_protocol_find(name);
+ if (rec != NULL) chat_protocol_destroy(rec);
+}
+
+/* Return the ID for the specified chat protocol. */
+int chat_protocol_lookup(const char *name)
+{
+ PROTOCOL_REC *rec;
+
+ g_return_val_if_fail(name != NULL, -1);
+
+ rec = chat_protocol_find(name);
+ return rec == NULL ? -1 : rec->id;
+}
+
+/* Return the name for the specified chat protocol ID. */
+const char *chat_protocol_get_name(int id)
+{
+ PROTOCOL_REC *rec;
+
+ g_return_val_if_fail(id > 0, NULL);
+
+ rec = chat_protocol_find_id(id);
+ return rec == NULL ? NULL : rec->name;
+}
+
+/* Return the full name for the specified chat protocol ID. */
+const char *chat_protocol_get_fullname(int id)
+{
+ PROTOCOL_REC *rec;
+
+ g_return_val_if_fail(id > 0, NULL);
+
+ rec = chat_protocol_find_id(id);
+ return rec == NULL ? NULL : rec->fullname;
+}
+
+/* Return the chatnet identifier name for the specified chat protocol ID. */
+const char *chat_protocol_get_chatnet(int id)
+{
+ PROTOCOL_REC *rec;
+
+ g_return_val_if_fail(id > 0, NULL);
+
+ rec = chat_protocol_find_id(id);
+ return rec == NULL ? NULL : rec->chatnet;
+}
+
+void chat_protocols_init(void)
+{
+ id_counter = 0;
+ protocols = NULL;
+}
+
+void chat_protocols_deinit(void)
+{
+ while (protocols != NULL)
+ chat_protocol_destroy(protocols->data);
+}
diff --git a/src/core/chat-protocols.h b/src/core/chat-protocols.h
new file mode 100644
index 00000000..42b413cf
--- /dev/null
+++ b/src/core/chat-protocols.h
@@ -0,0 +1,29 @@
+#ifndef __CHAT_PROTOCOLS_H
+#define __CHAT_PROTOCOLS_H
+
+#define PROTO_CHECK_CAST(object, cast, type_field, id) \
+ ((cast *) chat_protocol_check_cast(object, \
+ offsetof(cast, type_field), id))
+void *chat_protocol_check_cast(void *object, int type_pos, const char *id);
+
+/* Register new chat protocol. */
+void chat_protocol_register(const char *name,
+ const char *fullname,
+ const char *chatnet);
+
+/* Unregister chat protocol. */
+void chat_protocol_unregister(const char *name);
+
+/* Return the ID for the specified chat protocol. */
+int chat_protocol_lookup(const char *name);
+/* Return the name for the specified chat protocol ID. */
+const char *chat_protocol_get_name(int id);
+/* Return the full name for the specified chat protocol ID. */
+const char *chat_protocol_get_fullname(int id);
+/* Return the chatnet identifier name for the specified chat protocol ID. */
+const char *chat_protocol_get_chatnet(int id);
+
+void chat_protocols_init(void);
+void chat_protocols_deinit(void);
+
+#endif
diff --git a/src/core/chatnet-rec.h b/src/core/chatnet-rec.h
index e166627a..3044643a 100644
--- a/src/core/chatnet-rec.h
+++ b/src/core/chatnet-rec.h
@@ -1,5 +1,5 @@
-int type; /* should always be "CHATNET" */
-int chat_type;
+int type; /* module_get_uniq_id("CHATNET", 0) */
+int chat_type; /* chat_protocol_lookup(xx) */
char *name;
diff --git a/src/core/core.c b/src/core/core.c
index 48f4af8f..b1103f8c 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -27,6 +27,7 @@
#include "signals.h"
#include "settings.h"
+#include "chat-protocols.h"
#include "servers.h"
#include "chatnets.h"
#include "commands.h"
@@ -51,6 +52,7 @@ void core_init(void)
settings_init();
commands_init();
+ chat_protocols_init();
chatnets_init();
servers_init();
log_init();
@@ -73,6 +75,7 @@ void core_deinit(void)
log_deinit();
servers_deinit();
chatnets_deinit();
+ chat_protocols_deinit();
commands_deinit();
settings_deinit();
diff --git a/src/core/queries.c b/src/core/queries.c
index 17a371f9..f3e59184 100644
--- a/src/core/queries.c
+++ b/src/core/queries.c
@@ -84,7 +84,7 @@ static QUERY_REC *query_find_server(SERVER_REC *server, const char *nick)
for (tmp = server->queries; tmp != NULL; tmp = tmp->next) {
QUERY_REC *rec = tmp->data;
- if (rec->chat_type == server->query_type &&
+ if (rec->chat_type == server->chat_type &&
g_strcasecmp(nick, rec->name) == 0)
return rec;
}
diff --git a/src/core/server-connect-rec.h b/src/core/server-connect-rec.h
index 863235de..eea6739b 100644
--- a/src/core/server-connect-rec.h
+++ b/src/core/server-connect-rec.h
@@ -1,7 +1,7 @@
/* SERVER_CONNECT_REC definition, used for inheritance */
-int type;
-int chat_type;
+int type; /* module_get_uniq_id("SERVER CONNECT", 0) */
+int chat_type; /* chat_protocol_lookup(xx) */
/* if we're connecting via proxy, or just NULLs */
char *proxy;
diff --git a/src/core/server-rec.h b/src/core/server-rec.h
index 8aaabed2..61aaa2d8 100644
--- a/src/core/server-rec.h
+++ b/src/core/server-rec.h
@@ -1,7 +1,7 @@
/* SERVER_REC definition, used for inheritance */
-int type; /* should always be "SERVER" */
-int chat_type;
+int type; /* module_get_uniq_id("SERVER", 0) */
+int chat_type; /* chat_protocol_lookup(xx) */
STRUCT_SERVER_CONNECT_REC *connrec;
time_t connect_time; /* connection time */
@@ -42,9 +42,6 @@ GSList *queries;
/* support for multiple server types */
void *channel_find_func;
void *query_find_func;
-int channel_type;
-int query_type;
-
void *mask_match_func;
#undef STRUCT_SERVER_CONNECT_REC
diff --git a/src/core/server-setup-rec.h b/src/core/server-setup-rec.h
index 5158780d..5e6edb7f 100644
--- a/src/core/server-setup-rec.h
+++ b/src/core/server-setup-rec.h
@@ -1,5 +1,5 @@
-int type;
-int chat_type;
+int type; /* module_get_uniq_id("SERVER SETUP", 0) */
+int chat_type; /* chat_protocol_lookup(xx) */
char *chatnet;
diff --git a/src/core/window-item-rec.h b/src/core/window-item-rec.h
index 9cbfbabe..801a471e 100644
--- a/src/core/window-item-rec.h
+++ b/src/core/window-item-rec.h
@@ -1,7 +1,7 @@
/* WI_ITEM_REC definition, used for inheritance */
-int type; /* window item type - channel/query/.. */
-int chat_type; /* chat server type - irc/silc/.. */
+int type; /* module_get_uniq_id("CHANNEL/QUERY/xxx", 0) */
+int chat_type; /* chat_protocol_lookup(xx) */
GHashTable *module_data;
STRUCT_SERVER_REC *server;
diff --git a/src/fe-text/statusbar-items.c b/src/fe-text/statusbar-items.c
index ca1342ef..ea7c8ed5 100644
--- a/src/fe-text/statusbar-items.c
+++ b/src/fe-text/statusbar-items.c
@@ -132,15 +132,18 @@ static int statusbar_clock_timeout(void)
static void statusbar_nick(SBAR_ITEM_REC *item, int ypos)
{
CHANNEL_REC *channel;
- IRC_SERVER_REC *server;
+ SERVER_REC *server;
+ IRC_SERVER_REC *ircserver;
NICK_REC *nickrec;
int size_needed;
int umode_size;
char nick[10];
- server = (IRC_SERVER_REC *) (active_win == NULL ? NULL : active_win->active_server);
+ server = active_win == NULL ? NULL : active_win->active_server;
+ ircserver = IRC_SERVER(server);
- umode_size = server == NULL || server->usermode == NULL ? 0 : strlen(server->usermode)+3;
+ umode_size = ircserver == NULL || ircserver->usermode == NULL ? 0 :
+ strlen(ircserver->usermode)+3;
/* nick */
if (server == NULL || server->nick == NULL) {
@@ -151,7 +154,8 @@ static void statusbar_nick(SBAR_ITEM_REC *item, int ypos)
nick[9] = '\0';
channel = CHANNEL(active_win->active);
- nickrec = channel == NULL ? NULL : nicklist_find(channel, server->nick);
+ nickrec = channel == NULL ? NULL :
+ nicklist_find(channel, server->nick);
}
size_needed = 2 + strlen(nick) + umode_size +
@@ -176,7 +180,7 @@ static void statusbar_nick(SBAR_ITEM_REC *item, int ypos)
if (umode_size) {
set_color(stdscr, sbar_color_bold); addch('(');
set_color(stdscr, sbar_color_dim); addch('+');
- set_color(stdscr, sbar_color_normal); addstr(server->usermode);
+ set_color(stdscr, sbar_color_normal); addstr(ircserver->usermode);
set_color(stdscr, sbar_color_bold); addch(')');
}
if (server != NULL && server->usermode_away) {
@@ -519,7 +523,7 @@ static void statusbar_lag(SBAR_ITEM_REC *item, int ypos)
now = time(NULL);
str = g_string_new(NULL);
- server = (IRC_SERVER_REC *) (active_win == NULL ? NULL : active_win->active_server);
+ server = IRC_SERVER(active_win == NULL ? NULL : active_win->active_server);
if (server == NULL || server->lag_last_check == 0)
size_needed = 0;
else if (server->lag_sent == 0 || now-server->lag_sent < 5) {
diff --git a/src/irc/core/irc-channels.c b/src/irc/core/irc-channels.c
index de0822bd..eb63a865 100644
--- a/src/irc/core/irc-channels.c
+++ b/src/irc/core/irc-channels.c
@@ -52,7 +52,7 @@ IRC_CHANNEL_REC *irc_channel_create(IRC_SERVER_REC *server,
g_return_val_if_fail(name != NULL, NULL);
rec = g_new0(IRC_CHANNEL_REC, 1);
- rec->chat_type = module_get_uniq_id("IRC CHANNEL", 0);
+ rec->chat_type = IRC_PROTOCOL;
rec->name = g_strdup(name);
rec->server = server;
if (*name == '+') rec->no_modes = TRUE;
@@ -154,7 +154,7 @@ static CHANNEL_REC *irc_channel_find_server(SERVER_REC *server,
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
CHANNEL_REC *rec = tmp->data;
- if (rec->chat_type != server->channel_type)
+ if (rec->chat_type != server->chat_type)
continue;
if (g_strcasecmp(channel, rec->name) == 0)
@@ -175,7 +175,6 @@ static void sig_connected(SERVER_REC *server)
return;
server->channel_find_func = (void *) irc_channel_find_server;
- server->channel_type = module_get_uniq_id("IRC CHANNEL", 0);;
}
void irc_channels_init(void)
@@ -210,6 +209,4 @@ void irc_channels_deinit(void)
mode_lists_deinit();
massjoin_deinit();
irc_nicklist_deinit();
-
- module_uniq_destroy("IRC CHANNEL");
}
diff --git a/src/irc/core/irc-channels.h b/src/irc/core/irc-channels.h
index b4040bf5..5181378f 100644
--- a/src/irc/core/irc-channels.h
+++ b/src/irc/core/irc-channels.h
@@ -1,12 +1,13 @@
#ifndef __IRC_CHANNELS_H
#define __IRC_CHANNELS_H
+#include "chat-protocols.h"
#include "channels.h"
#include "irc-servers.h"
/* Returns IRC_CHANNEL_REC if it's IRC channel, NULL if it isn't. */
#define IRC_CHANNEL(channel) \
- MODULE_CHECK_CAST(channel, IRC_CHANNEL_REC, chat_type, "IRC CHANNEL")
+ PROTO_CHECK_CAST(CHANNEL(channel), IRC_CHANNEL_REC, chat_type, "IRC")
#define IS_IRC_CHANNEL(channel) \
(IRC_CHANNEL(channel) ? TRUE : FALSE)
diff --git a/src/irc/core/irc-chatnets.c b/src/irc/core/irc-chatnets.c
index 5128d57f..4eda9401 100644
--- a/src/irc/core/irc-chatnets.c
+++ b/src/irc/core/irc-chatnets.c
@@ -36,7 +36,7 @@ static void ircnet_read(CONFIG_NODE *node)
return;
rec = g_new0(IRC_CHATNET_REC, 1);
- rec->chat_type = module_get_uniq_id("IRC CHATNET", 0);
+ rec->chat_type = IRC_PROTOCOL;
rec->max_cmds_at_once = config_node_get_int(node, "cmdmax", 0);
rec->cmd_queue_speed = config_node_get_int(node, "cmdspeed", 0);
@@ -87,7 +87,7 @@ void ircnet_create(IRC_CHATNET_REC *rec)
{
g_return_if_fail(rec != NULL);
- rec->chat_type = module_get_uniq_id("IRC CHATNET", 0);
+ rec->chat_type = IRC_PROTOCOL;
ircnet_save(rec);
chatnet_create(CHATNET(rec));
@@ -127,6 +127,4 @@ void irc_chatnets_deinit(void)
{
signal_remove("chatnet removed", (SIGNAL_FUNC) sig_chatnet_removed);
signal_remove("setup reread", (SIGNAL_FUNC) read_ircnets);
-
- module_uniq_destroy("IRC CHATNET");
}
diff --git a/src/irc/core/irc-chatnets.h b/src/irc/core/irc-chatnets.h
index 151bca8e..2890b33e 100644
--- a/src/irc/core/irc-chatnets.h
+++ b/src/irc/core/irc-chatnets.h
@@ -1,11 +1,12 @@
#ifndef __IRC_CHATNETS_H
#define __IRC_CHATNETS_H
-#include "modules.h"
+#include "chat-protocols.h"
+#include "chatnets.h"
/* returns IRC_CHATNET_REC if it's IRC network, NULL if it isn't */
#define IRC_CHATNET(chatnet) \
- MODULE_CHECK_CAST(chatnet, IRC_CHATNET_REC, chat_type, "IRC CHATNET")
+ PROTO_CHECK_CAST(CHATNET(chatnet), IRC_CHATNET_REC, chat_type, "IRC")
#define IS_IRC_CHATNET(chatnet) \
(IRC_CHATNET(chatnet) ? TRUE : FALSE)
diff --git a/src/irc/core/irc-core.c b/src/irc/core/irc-core.c
index afdc00c2..a6ff310a 100644
--- a/src/irc/core/irc-core.c
+++ b/src/irc/core/irc-core.c
@@ -19,6 +19,7 @@
*/
#include "module.h"
+#include "chat-protocols.h"
#include "irc-servers.h"
#include "irc-channels.h"
@@ -49,6 +50,8 @@ void irc_channels_setup_deinit(void);
void irc_core_init(void)
{
+ chat_protocol_register("IRC", "Internet Relay Chat", "ircnet");
+
irc_servers_init();
irc_channels_init();
irc_queries_init();
@@ -81,4 +84,6 @@ void irc_core_deinit(void)
irc_channels_deinit();
irc_irc_deinit();
irc_servers_deinit();
+
+ chat_protocol_unregister("IRC");
}
diff --git a/src/irc/core/irc-queries.c b/src/irc/core/irc-queries.c
index b013d9cf..d2dfee1c 100644
--- a/src/irc/core/irc-queries.c
+++ b/src/irc/core/irc-queries.c
@@ -34,21 +34,13 @@ QUERY_REC *irc_query_create(IRC_SERVER_REC *server,
g_return_val_if_fail(nick != NULL, NULL);
rec = g_new0(QUERY_REC, 1);
- rec->chat_type = module_get_uniq_id("IRC QUERY", 0);
+ rec->chat_type = IRC_PROTOCOL;
rec->name = g_strdup(nick);
rec->server = (SERVER_REC *) server;
query_init(rec, automatic);
return rec;
}
-static void sig_connected(SERVER_REC *server)
-{
- if (!IS_IRC_SERVER(server))
- return;
-
- server->query_type = module_get_uniq_id("IRC QUERY", 0);;
-}
-
static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *nick, const char *addr)
{
char *params, *target, *msg;
@@ -94,16 +86,12 @@ static void event_nick(const char *data, IRC_SERVER_REC *server, const char *ori
void irc_queries_init(void)
{
- signal_add("server connected", (SIGNAL_FUNC) sig_connected);
signal_add_last("event privmsg", (SIGNAL_FUNC) event_privmsg);
signal_add("event nick", (SIGNAL_FUNC) event_nick);
}
void irc_queries_deinit(void)
{
- signal_remove("server connected", (SIGNAL_FUNC) sig_connected);
signal_remove("event privmsg", (SIGNAL_FUNC) event_privmsg);
signal_remove("event nick", (SIGNAL_FUNC) event_nick);
-
- module_uniq_destroy("IRC QUERY");
}
diff --git a/src/irc/core/irc-queries.h b/src/irc/core/irc-queries.h
index c217c9be..ad3f0329 100644
--- a/src/irc/core/irc-queries.h
+++ b/src/irc/core/irc-queries.h
@@ -1,12 +1,13 @@
#ifndef __IRC_QUERIES_H
#define __IRC_QUERIES_H
+#include "chat-protocols.h"
#include "queries.h"
#include "irc-servers.h"
/* Returns IRC_QUERY_REC if it's IRC query, NULL if it isn't. */
#define IRC_QUERY(query) \
- MODULE_CHECK_CAST(query, QUERY_REC, chat_type, "IRC QUERY")
+ PROTO_CHECK_CAST(QUERY(query), QUERY_REC, chat_type, "IRC")
#define IS_IRC_QUERY(query) \
(IRC_QUERY(query) ? TRUE : FALSE)
diff --git a/src/irc/core/irc-servers-reconnect.c b/src/irc/core/irc-servers-reconnect.c
index 4ba1d51a..2b44ea4b 100644
--- a/src/irc/core/irc-servers-reconnect.c
+++ b/src/irc/core/irc-servers-reconnect.c
@@ -39,7 +39,7 @@ static void sig_server_connect_copy(SERVER_CONNECT_REC **dest,
return;
rec = g_new0(IRC_SERVER_CONNECT_REC, 1);
- rec->chat_type = module_get_uniq_id("IRC SERVER CONNECT", 0);
+ rec->chat_type = IRC_PROTOCOL;
rec->cmd_queue_speed = src->cmd_queue_speed;
rec->max_kicks = src->max_kicks;
rec->max_modes = src->max_modes;
diff --git a/src/irc/core/irc-servers-setup.c b/src/irc/core/irc-servers-setup.c
index 73a3fa9b..0dbd6297 100644
--- a/src/irc/core/irc-servers-setup.c
+++ b/src/irc/core/irc-servers-setup.c
@@ -55,7 +55,7 @@ static void sig_server_create_conn(SERVER_CONNECT_REC **conn,
return;
rec = g_new0(IRC_SERVER_CONNECT_REC, 1);
- rec->chat_type = module_get_uniq_id("IRC SERVER CONNECT", 0);
+ rec->chat_type = IRC_PROTOCOL;
rec->alternate_nick = g_strdup(settings_get_str("alternate_nick"));
*conn = (SERVER_CONNECT_REC *) rec;
@@ -150,7 +150,7 @@ static void sig_server_setup_read(SERVER_SETUP_REC **setuprec,
return;
rec = g_new0(IRC_SERVER_SETUP_REC, 1);
- rec->chat_type = module_get_uniq_id("IRC SERVER SETUP", 0);
+ rec->chat_type = IRC_PROTOCOL;
rec->max_cmds_at_once = config_node_get_int(node, "cmds_max_at_once", 0);
rec->cmd_queue_speed = config_node_get_int(node, "cmd_queue_speed", 0);
@@ -191,6 +191,4 @@ void irc_servers_setup_deinit(void)
signal_remove("server setup fill chatnet", (SIGNAL_FUNC) sig_server_setup_fill_chatnet);
signal_remove("server setup read", (SIGNAL_FUNC) sig_server_setup_read);
signal_remove("server setup saved", (SIGNAL_FUNC) sig_server_setup_saved);
-
- module_uniq_destroy("IRC SERVER SETUP");
}
diff --git a/src/irc/core/irc-servers-setup.h b/src/irc/core/irc-servers-setup.h
index 818611fe..65739f79 100644
--- a/src/irc/core/irc-servers-setup.h
+++ b/src/irc/core/irc-servers-setup.h
@@ -1,10 +1,12 @@
#ifndef __IRC_SERVERS_SETUP_H
#define __IRC_SERVERS_SETUP_H
+#include "chat-protocols.h"
+#include "servers-setup.h"
#define IRC_SERVER_SETUP(server) \
- MODULE_CHECK_CAST(server, IRC_SERVER_SETUP_REC, \
- chat_type, "IRC SERVER SETUP")
+ PROTO_CHECK_CAST(SERVER_SETUP(server), IRC_SERVER_SETUP_REC, \
+ chat_type, "IRC")
#define IS_IRC_SERVER_SETUP(server) \
(IRC_SERVER_SETUP(server) ? TRUE : FALSE)
diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c
index 3f9593b8..d51f2af5 100644
--- a/src/irc/core/irc-servers.c
+++ b/src/irc/core/irc-servers.c
@@ -112,7 +112,7 @@ IRC_SERVER_REC *irc_server_connect(IRC_SERVER_CONNECT_REC *conn)
if (conn->nick == NULL || *conn->nick == '\0') return NULL;
server = g_new0(IRC_SERVER_REC, 1);
- server->chat_type = module_get_uniq_id("IRC SERVER", 0);
+ server->chat_type = IRC_PROTOCOL;
server->connrec = conn;
if (server->connrec->port <= 0) server->connrec->port = 6667;
@@ -425,6 +425,4 @@ void irc_servers_deinit(void)
irc_chatnets_deinit();
irc_servers_reconnect_deinit();
servers_idle_deinit();
-
- module_uniq_destroy("IRC SERVER");
}
diff --git a/src/irc/core/irc-servers.h b/src/irc/core/irc-servers.h
index e1fd333d..1541693f 100644
--- a/src/irc/core/irc-servers.h
+++ b/src/irc/core/irc-servers.h
@@ -1,15 +1,16 @@
#ifndef __IRC_SERVERS_H
#define __IRC_SERVERS_H
+#include "chat-protocols.h"
#include "servers.h"
/* returns IRC_SERVER_REC if it's IRC server, NULL if it isn't */
#define IRC_SERVER(server) \
- MODULE_CHECK_CAST(server, IRC_SERVER_REC, chat_type, "IRC SERVER")
+ PROTO_CHECK_CAST(SERVER(server), IRC_SERVER_REC, chat_type, "IRC")
#define IRC_SERVER_CONNECT(conn) \
- MODULE_CHECK_CAST(conn, IRC_SERVER_CONNECT_REC, \
- chat_type, "IRC SERVER CONNECT")
+ PROTO_CHECK_CAST(SERVER_CONNECT(conn), IRC_SERVER_CONNECT_REC, \
+ chat_type, "IRC")
#define IS_IRC_SERVER(server) \
(IRC_SERVER(server) ? TRUE : FALSE)
diff --git a/src/irc/core/irc.c b/src/irc/core/irc.c
index 1b366850..3940f000 100644
--- a/src/irc/core/irc.c
+++ b/src/irc/core/irc.c
@@ -404,6 +404,4 @@ void irc_irc_deinit(void)
signal_remove("server event", (SIGNAL_FUNC) irc_server_event);
signal_remove("server connected", (SIGNAL_FUNC) irc_init_server);
signal_remove("server incoming", (SIGNAL_FUNC) irc_parse_incoming_line);
-
- module_uniq_destroy("IRC");
}
diff --git a/src/irc/core/module.h b/src/irc/core/module.h
index 00599d91..a605302b 100644
--- a/src/irc/core/module.h
+++ b/src/irc/core/module.h
@@ -2,3 +2,4 @@
#define MODULE_NAME "irc/core"
+#define IRC_PROTOCOL (chat_protocol_lookup("IRC"))