Moved some stuff from irc to core. Added command_bind_proto() function to

bind protocol-specific commands. Added #define command_bind_irc() for easier
access. CMD_IRC_SERVER(server) check should be done at the beginning of each
command requiring IRC server as active server, it handles it correctly the
cases when it is not. Did some other cleanups as well.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1955 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-11-02 01:05:14 +00:00 committed by cras
commit f354fe54c7
70 changed files with 381 additions and 438 deletions

View file

@ -29,6 +29,5 @@ libfe_common_irc_a_SOURCES = \
module-formats.c
noinst_HEADERS = \
fe-common-irc.h \
module.h \
module-formats.h

View file

@ -1,3 +1,4 @@
#include "common.h"
#include "irc.h"
#define MODULE_NAME "fe-common/irc/dcc"

View file

@ -23,7 +23,6 @@
#include "misc.h"
#include "settings.h"
#include "irc.h"
#include "levels.h"
#include "servers.h"
#include "channels.h"

View file

@ -23,10 +23,9 @@
#include "signals.h"
#include "misc.h"
#include "settings.h"
#include "irc.h"
#include "levels.h"
#include "servers.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "nicklist.h"

View file

@ -24,7 +24,6 @@
#include "misc.h"
#include "settings.h"
#include "irc.h"
#include "levels.h"
#include "servers.h"
#include "servers-redirect.h"
@ -32,12 +31,14 @@
#include "queries.h"
#include "ignore.h"
#include "fe-queries.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "irc-nicklist.h"
#include "irc-masks.h"
#include "fe-windows.h"
#include "printtext.h"
#include "fe-queries.h"
#include "fe-windows.h"
#include "completion.h"

View file

@ -21,16 +21,13 @@
#include "module.h"
#include "module-formats.h"
#include "signals.h"
#include "commands.h"
#include "levels.h"
#include "servers.h"
#include "irc.h"
#include "channel-rejoin.h"
#include "printtext.h"
static void sig_channel_rejoin(IRC_SERVER_REC *server, REJOIN_REC *rec)
static void sig_channel_rejoin(SERVER_REC *server, REJOIN_REC *rec)
{
g_return_if_fail(rec != NULL);
@ -38,22 +35,12 @@ static void sig_channel_rejoin(IRC_SERVER_REC *server, REJOIN_REC *rec)
IRCTXT_CHANNEL_REJOIN, rec->channel);
}
static void cmd_channel(const char *data, SERVER_REC *server)
{
if (ischannel(*data)) {
signal_emit("command join", 2, data, server);
signal_stop();
}
}
void fe_irc_channels_init(void)
{
signal_add("channel rejoin new", (SIGNAL_FUNC) sig_channel_rejoin);
command_bind("channel", NULL, (SIGNAL_FUNC) cmd_channel);
}
void fe_irc_channels_deinit(void)
{
signal_remove("channel rejoin new", (SIGNAL_FUNC) sig_channel_rejoin);
command_unbind("channel", (SIGNAL_FUNC) cmd_channel);
}

View file

@ -21,16 +21,16 @@
#include "module.h"
#include "module-formats.h"
#include "signals.h"
#include "commands.h"
#include "misc.h"
#include "special-vars.h"
#include "settings.h"
#include "levels.h"
#include "irc.h"
#include "servers.h"
#include "mode-lists.h"
#include "nicklist.h"
#include "irc-commands.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "irc-queries.h"
@ -56,8 +56,7 @@ static char *skip_target(char *target)
/* SYNTAX: ME <message> */
static void cmd_me(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
{
g_return_if_fail(data != NULL);
CMD_IRC_SERVER(server);
if (!IS_IRC_ITEM(item))
return;
@ -76,9 +75,7 @@ static void cmd_action(const char *data, IRC_SERVER_REC *server)
char *target, *text;
void *free_arg;
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST,
&target, &text))
@ -98,9 +95,7 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server)
char *target, *msg;
void *free_arg;
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST,
&target, &msg))
@ -118,9 +113,7 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server)
char *target, *ctcpcmd, *ctcpdata;
void *free_arg;
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
&target, &ctcpcmd, &ctcpdata))
@ -148,9 +141,7 @@ static void cmd_nctcp(const char *data, IRC_SERVER_REC *server)
char *target, *text;
void *free_arg;
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST,
&target, &text))
@ -170,9 +161,7 @@ static void cmd_wall(const char *data, IRC_SERVER_REC *server,
char *channame, *msg;
void *free_arg;
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected || !IS_IRC_SERVER(server))
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN |
PARAM_FLAG_GETREST, item, &channame, &msg))
@ -249,9 +238,7 @@ static void cmd_ban(const char *data, IRC_SERVER_REC *server,
char *channel, *nicks;
void *free_arg;
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (!cmd_get_params(data, &free_arg, 2 |
PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST,
@ -290,8 +277,7 @@ static void cmd_invitelist(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC
IRC_CHANNEL_REC *channel, *cur_channel;
GSList *tmp;
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
cur_channel = IRC_CHANNEL(item);
if (cur_channel == NULL) cmd_return_error(CMDERR_NOT_JOINED);
@ -317,28 +303,6 @@ static void cmd_invitelist(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC
}
}
static void cmd_join(const char *data, IRC_SERVER_REC *server)
{
if ((*data == '\0' || g_strncasecmp(data, "-invite", 7) == 0) &&
server != NULL && server->last_invite == NULL) {
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NOT_INVITED);
signal_stop();
}
}
static void cmd_nick(const char *data, IRC_SERVER_REC *server)
{
g_return_if_fail(data != NULL);
if (*data != '\0') return;
if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
/* display current nick */
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_YOUR_NICK, server->nick);
signal_stop();
}
/* SYNTAX: VER [<target>] */
static void cmd_ver(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
{
@ -346,8 +310,7 @@ static void cmd_ver(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
g_return_if_fail(data != NULL);
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (*data == '\0' && !IS_IRC_ITEM(item))
cmd_return_error(CMDERR_NOT_JOINED);
@ -465,21 +428,19 @@ static void cmd_sethost(const char *data, IRC_SERVER_REC *server)
void fe_irc_commands_init(void)
{
command_bind_last("me", NULL, (SIGNAL_FUNC) cmd_me);
command_bind_last("action", NULL, (SIGNAL_FUNC) cmd_action);
command_bind("notice", NULL, (SIGNAL_FUNC) cmd_notice);
command_bind("ctcp", NULL, (SIGNAL_FUNC) cmd_ctcp);
command_bind("nctcp", NULL, (SIGNAL_FUNC) cmd_nctcp);
command_bind("wall", NULL, (SIGNAL_FUNC) cmd_wall);
command_bind("ban", NULL, (SIGNAL_FUNC) cmd_ban);
command_bind("invitelist", NULL, (SIGNAL_FUNC) cmd_invitelist);
command_bind("join", NULL, (SIGNAL_FUNC) cmd_join);
command_bind("nick", NULL, (SIGNAL_FUNC) cmd_nick);
command_bind("ver", NULL, (SIGNAL_FUNC) cmd_ver);
command_bind("topic", NULL, (SIGNAL_FUNC) cmd_topic);
command_bind("ts", NULL, (SIGNAL_FUNC) cmd_ts);
command_bind("oper", NULL, (SIGNAL_FUNC) cmd_oper);
command_bind("sethost", NULL, (SIGNAL_FUNC) cmd_sethost);
command_bind_irc_last("me", NULL, (SIGNAL_FUNC) cmd_me);
command_bind_irc_last("action", NULL, (SIGNAL_FUNC) cmd_action);
command_bind_irc("notice", NULL, (SIGNAL_FUNC) cmd_notice);
command_bind_irc("ctcp", NULL, (SIGNAL_FUNC) cmd_ctcp);
command_bind_irc("nctcp", NULL, (SIGNAL_FUNC) cmd_nctcp);
command_bind_irc("wall", NULL, (SIGNAL_FUNC) cmd_wall);
command_bind_irc("ban", NULL, (SIGNAL_FUNC) cmd_ban);
command_bind_irc("invitelist", NULL, (SIGNAL_FUNC) cmd_invitelist);
command_bind_irc("ver", NULL, (SIGNAL_FUNC) cmd_ver);
command_bind_irc("topic", NULL, (SIGNAL_FUNC) cmd_topic);
command_bind_irc("ts", NULL, (SIGNAL_FUNC) cmd_ts);
command_bind_irc("oper", NULL, (SIGNAL_FUNC) cmd_oper);
command_bind_irc("sethost", NULL, (SIGNAL_FUNC) cmd_sethost);
}
void fe_irc_commands_deinit(void)
@ -492,8 +453,6 @@ void fe_irc_commands_deinit(void)
command_unbind("wall", (SIGNAL_FUNC) cmd_wall);
command_unbind("ban", (SIGNAL_FUNC) cmd_ban);
command_unbind("invitelist", (SIGNAL_FUNC) cmd_invitelist);
command_unbind("join", (SIGNAL_FUNC) cmd_join);
command_unbind("nick", (SIGNAL_FUNC) cmd_nick);
command_unbind("ver", (SIGNAL_FUNC) cmd_ver);
command_unbind("topic", (SIGNAL_FUNC) cmd_topic);
command_unbind("ts", (SIGNAL_FUNC) cmd_ts);

View file

@ -25,7 +25,7 @@
#include "ignore.h"
#include "settings.h"
#include "irc.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "irc-queries.h"

View file

@ -24,8 +24,6 @@
#include "queries.h"
#include "nicklist.h"
#include "irc.h"
static QUERY_REC *query_find_address(SERVER_REC *server, const char *address)
{
GSList *tmp;

View file

@ -165,7 +165,7 @@ static void cmd_ircnet_remove(const char *data)
}
}
static void cmd_ircnet(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
static void cmd_ircnet(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
{
if (*data == '\0')
cmd_ircnet_list();

View file

@ -25,7 +25,6 @@
#include "misc.h"
#include "settings.h"
#include "irc.h"
#include "irc-servers.h"
#include "irc-channels.h"
#include "modes.h"

View file

@ -25,7 +25,6 @@
#include "misc.h"
#include "settings.h"
#include "irc.h"
#include "irc-servers.h"
#include "modes.h"
#include "ignore.h"

View file

@ -21,12 +21,11 @@
#include "module.h"
#include "module-formats.h"
#include "signals.h"
#include "commands.h"
#include "levels.h"
#include "settings.h"
#include "irc.h"
#include "irc-servers.h"
#include "irc-commands.h"
#include "ignore.h"
#include "netsplit.h"
@ -322,8 +321,7 @@ static void cmd_netsplit(const char *data, IRC_SERVER_REC *server)
{
GSList *list;
if (!IS_IRC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
CMD_IRC_SERVER(server);
if (server->split_servers == NULL) {
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
@ -360,7 +358,7 @@ void fe_netsplit_init(void)
read_settings();
signal_add("netsplit new", (SIGNAL_FUNC) sig_netsplit_servers);
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
command_bind("netsplit", NULL, (SIGNAL_FUNC) cmd_netsplit);
command_bind_irc("netsplit", NULL, (SIGNAL_FUNC) cmd_netsplit);
}
void fe_netsplit_deinit(void)

View file

@ -58,7 +58,6 @@ FORMAT_REC fecommon_irc_formats[] = {
{ "joinerror_duplicate", "Channel {channel $0} already exists - cannot create it", 1, { 0 } },
{ "channel_rejoin", "Channel {channel $0} is temporarily unavailable, this is normally because of netsplits. Irssi will now automatically try to rejoin back to this channel until the join is successful. Use /RMREJOINS command if you wish to abort this.", 1, { 0 } },
{ "inviting", "Inviting {nick $0} to {channel $1}", 2, { 0, 0 } },
{ "not_invited", "You have not been invited to a channel!", 0 },
{ "channel_created", "Channel {channelhilight $0} created $1", 2, { 0, 0 } },
{ "url", "Home page for {channelhilight $0}: $1", 2, { 0, 0 } },
{ "topic", "Topic for {channelhilight $0}: $1", 2, { 0, 0 } },
@ -87,7 +86,6 @@ FORMAT_REC fecommon_irc_formats[] = {
{ "unaway", "You are no longer marked as being away", 0 },
{ "nick_away", "{nick $0} is away: $1", 2, { 0, 0 } },
{ "no_such_nick", "{nick $0}: No such nick/channel", 1, { 0 } },
{ "your_nick", "Your nickname is {nick $0}", 1, { 0 } },
{ "nick_in_use", "Nick {nick $0} is already in use", 1, { 0 } },
{ "nick_unavailable", "Nick {nick $0} is temporarily unavailable", 1, { 0 } },
{ "your_nick_owned", "Your nick is owned by {nick $3} {comment $1@$2}", 4, { 0, 0, 0, 0 } },

View file

@ -35,7 +35,6 @@ enum {
IRCTXT_JOINERROR_DUPLICATE,
IRCTXT_CHANNEL_REJOIN,
IRCTXT_INVITING,
IRCTXT_NOT_INVITED,
IRCTXT_CHANNEL_CREATED,
IRCTXT_CHANNEL_URL,
IRCTXT_TOPIC,
@ -63,7 +62,6 @@ enum {
IRCTXT_UNAWAY,
IRCTXT_NICK_AWAY,
IRCTXT_NO_SUCH_NICK,
IRCTXT_YOUR_NICK,
IRCTXT_NICK_IN_USE,
IRCTXT_NICK_UNAVAILABLE,
IRCTXT_YOUR_NICK_OWNED,

View file

@ -1,3 +1,4 @@
#include "common.h"
#include "irc.h"
#define MODULE_NAME "fe-common/irc"

View file

@ -1,3 +1,4 @@
#include "common.h"
#include "irc.h"
#define MODULE_NAME "fe-common/irc/notifylist"