mirror of
https://github.com/irssi/irssi.git
synced 2026-08-11 21:00:40 +02:00
Updates.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@641 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
28a7908e73
commit
755a8d40eb
31 changed files with 386 additions and 217 deletions
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue