mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05: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
@ -28,6 +28,21 @@ typedef CHANNEL_REC *(*CHANNEL_FIND_FUNC)(SERVER_REC *, const char *);
|
||||
|
||||
GSList *channels; /* List of all channels */
|
||||
|
||||
/* Create a new channel */
|
||||
CHANNEL_REC *channel_create(int chat_type, SERVER_REC *server,
|
||||
const char *name, int automatic)
|
||||
{
|
||||
CHANNEL_REC *channel;
|
||||
|
||||
g_return_val_if_fail(server == NULL || IS_SERVER(server), NULL);
|
||||
g_return_val_if_fail(name != NULL, NULL);
|
||||
|
||||
channel = NULL;
|
||||
signal_emit("channel create", 5, &channel, GINT_TO_POINTER(chat_type),
|
||||
server, name, GINT_TO_POINTER(automatic));
|
||||
return channel;
|
||||
}
|
||||
|
||||
void channel_init(CHANNEL_REC *channel, int automatic)
|
||||
{
|
||||
g_return_if_fail(channel != NULL);
|
||||
@ -40,7 +55,7 @@ void channel_init(CHANNEL_REC *channel, int automatic)
|
||||
}
|
||||
|
||||
MODULE_DATA_INIT(channel);
|
||||
channel->type = module_get_uniq_id("CHANNEL", 0);
|
||||
channel->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "CHANNEL");
|
||||
channel->mode = g_strdup("");
|
||||
channel->createtime = time(NULL);
|
||||
|
||||
|
@ -5,7 +5,8 @@
|
||||
|
||||
/* Returns CHANNEL_REC if it's channel, NULL if it isn't. */
|
||||
#define CHANNEL(channel) \
|
||||
MODULE_CHECK_CAST(channel, CHANNEL_REC, type, "CHANNEL")
|
||||
MODULE_CHECK_CAST_MODULE(channel, CHANNEL_REC, type, \
|
||||
"WINDOW ITEM TYPE", "CHANNEL")
|
||||
|
||||
#define IS_CHANNEL(channel) \
|
||||
(CHANNEL(channel) ? TRUE : FALSE)
|
||||
@ -17,8 +18,9 @@ typedef struct {
|
||||
|
||||
extern GSList *channels;
|
||||
|
||||
void channels_init(void);
|
||||
void channels_deinit(void);
|
||||
/* Create a new channel */
|
||||
CHANNEL_REC *channel_create(int chat_type, SERVER_REC *server,
|
||||
const char *name, int automatic);
|
||||
|
||||
/* Create new channel record */
|
||||
void channel_init(CHANNEL_REC *channel, int automatic);
|
||||
@ -27,4 +29,7 @@ void channel_destroy(CHANNEL_REC *channel);
|
||||
/* find channel by name, if `server' is NULL, search from all servers */
|
||||
CHANNEL_REC *channel_find(SERVER_REC *server, const char *name);
|
||||
|
||||
void channels_init(void);
|
||||
void channels_deinit(void);
|
||||
|
||||
#endif
|
||||
|
@ -30,8 +30,16 @@ static int next_uniq_id;
|
||||
|
||||
void *module_check_cast(void *object, int type_pos, const char *id)
|
||||
{
|
||||
return object == NULL ||
|
||||
module_find_id(id, G_STRUCT_MEMBER(int, object, type_pos)) == -1 ? NULL : object;
|
||||
return object == NULL || module_find_id(id,
|
||||
G_STRUCT_MEMBER(int, object, type_pos)) == -1 ? NULL : object;
|
||||
}
|
||||
|
||||
void *module_check_cast_module(void *object, int type_pos,
|
||||
const char *module, const char *id)
|
||||
{
|
||||
return object == NULL || strcmp(module_find_id_str(module,
|
||||
G_STRUCT_MEMBER(int, object, type_pos)), id) == 0 ?
|
||||
NULL : object;
|
||||
}
|
||||
|
||||
/* return unique number across all modules for `id' */
|
||||
|
@ -33,7 +33,12 @@ void module_unload(MODULE_REC *module);
|
||||
|
||||
#define MODULE_CHECK_CAST(object, cast, type_field, id) \
|
||||
((cast *) module_check_cast(object, offsetof(cast, type_field), id))
|
||||
#define MODULE_CHECK_CAST_MODULE(object, cast, type_field, module, id) \
|
||||
((cast *) module_check_cast_module(object, \
|
||||
offsetof(cast, type_field), module, id))
|
||||
void *module_check_cast(void *object, int type_pos, const char *id);
|
||||
void *module_check_cast_module(void *object, int type_pos,
|
||||
const char *module, const char *id);
|
||||
|
||||
/* return unique number across all modules for `id' */
|
||||
int module_get_uniq_id(const char *module, int id);
|
||||
|
@ -28,6 +28,21 @@ GSList *queries;
|
||||
|
||||
typedef QUERY_REC *(*QUERY_FIND_FUNC)(SERVER_REC *, const char *);
|
||||
|
||||
/* Create a new query */
|
||||
QUERY_REC *query_create(int chat_type, SERVER_REC *server,
|
||||
const char *nick, int automatic)
|
||||
{
|
||||
QUERY_REC *query;
|
||||
|
||||
g_return_val_if_fail(server == NULL || IS_SERVER(server), NULL);
|
||||
g_return_val_if_fail(nick != NULL, NULL);
|
||||
|
||||
query = NULL;
|
||||
signal_emit("query create", 5, &query, GINT_TO_POINTER(chat_type),
|
||||
server, nick, GINT_TO_POINTER(automatic));
|
||||
return query;
|
||||
}
|
||||
|
||||
void query_init(QUERY_REC *query, int automatic)
|
||||
{
|
||||
g_return_if_fail(query != NULL);
|
||||
@ -40,7 +55,7 @@ void query_init(QUERY_REC *query, int automatic)
|
||||
}
|
||||
|
||||
MODULE_DATA_INIT(query);
|
||||
query->type = module_get_uniq_id("QUERY", 0);
|
||||
query->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "QUERY");
|
||||
if (query->server != NULL)
|
||||
query->server_tag = g_strdup(query->server->tag);
|
||||
|
||||
|
@ -5,7 +5,8 @@
|
||||
|
||||
/* Returns QUERY_REC if it's query, NULL if it isn't. */
|
||||
#define QUERY(query) \
|
||||
MODULE_CHECK_CAST(query, QUERY_REC, type, "QUERY")
|
||||
MODULE_CHECK_CAST_MODULE(query, QUERY_REC, type, \
|
||||
"WINDOW ITEM TYPE", "QUERY")
|
||||
|
||||
#define IS_QUERY(query) \
|
||||
(QUERY(query) ? TRUE : FALSE)
|
||||
@ -20,6 +21,10 @@ extern GSList *queries;
|
||||
void query_init(QUERY_REC *query, int automatic);
|
||||
void query_destroy(QUERY_REC *query);
|
||||
|
||||
/* Create a new query */
|
||||
QUERY_REC *query_create(int chat_type, SERVER_REC *server,
|
||||
const char *nick, int automatic);
|
||||
|
||||
/* Find query by name, if `server' is NULL, search from all servers */
|
||||
QUERY_REC *query_find(SERVER_REC *server, const char *nick);
|
||||
|
||||
|
@ -114,6 +114,7 @@ server_connect_copy_skeleton(SERVER_CONNECT_REC *src)
|
||||
signal_emit("server connect copy", 2, &dest, src);
|
||||
g_return_val_if_fail(dest != NULL, NULL);
|
||||
|
||||
dest->type = module_get_uniq_id("SERVER CONNECT", 0);
|
||||
dest->proxy = g_strdup(src->proxy);
|
||||
dest->proxy_port = src->proxy_port;
|
||||
dest->proxy_string = g_strdup(src->proxy_string);
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "module.h"
|
||||
#include "signals.h"
|
||||
#include "commands.h"
|
||||
#include "line-split.h"
|
||||
#include "net-nonblock.h"
|
||||
#include "net-sendbuffer.h"
|
||||
@ -28,6 +29,7 @@
|
||||
#include "settings.h"
|
||||
|
||||
#include "servers.h"
|
||||
#include "servers-reconnect.h"
|
||||
#include "servers-redirect.h"
|
||||
#include "servers-setup.h"
|
||||
#include "channels.h"
|
||||
@ -397,10 +399,49 @@ void server_connect_free(SERVER_CONNECT_REC *conn)
|
||||
g_free(conn);
|
||||
}
|
||||
|
||||
/* `optlist' should contain only one key - the server tag.
|
||||
returns NULL if there was unknown -option */
|
||||
SERVER_REC *cmd_options_get_server(const char *cmd,
|
||||
GHashTable *optlist,
|
||||
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 server;
|
||||
}
|
||||
|
||||
void servers_init(void)
|
||||
{
|
||||
lookup_servers = servers = NULL;
|
||||
|
||||
servers_reconnect_init();
|
||||
servers_redirect_init();
|
||||
servers_setup_init();
|
||||
}
|
||||
@ -414,6 +455,7 @@ void servers_deinit(void)
|
||||
|
||||
servers_setup_deinit();
|
||||
servers_redirect_deinit();
|
||||
servers_reconnect_deinit();
|
||||
|
||||
module_uniq_destroy("SERVER");
|
||||
module_uniq_destroy("SERVER CONNECT");
|
||||
|
@ -48,4 +48,10 @@ SERVER_REC *server_find_chatnet(const char *chatnet);
|
||||
int server_start_connect(SERVER_REC *server);
|
||||
void server_connect_free(SERVER_CONNECT_REC *conn);
|
||||
|
||||
/* `optlist' should contain only one key - the server tag.
|
||||
returns NULL if there was unknown -option */
|
||||
SERVER_REC *cmd_options_get_server(const char *cmd,
|
||||
GHashTable *optlist,
|
||||
SERVER_REC *defserver);
|
||||
|
||||
#endif
|
||||
|
@ -10,10 +10,12 @@ libfe_common_core_a_SOURCES = \
|
||||
autorun.c \
|
||||
command-history.c \
|
||||
completion.c \
|
||||
fe-channels.c \
|
||||
fe-common-core.c \
|
||||
fe-core-commands.c \
|
||||
fe-log.c \
|
||||
fe-modules.c \
|
||||
fe-queries.c \
|
||||
fe-server.c \
|
||||
fe-settings.c \
|
||||
hilight-text.c \
|
||||
@ -32,6 +34,7 @@ noinst_HEADERS = \
|
||||
command-history.h \
|
||||
completion.h \
|
||||
fe-common-core.h \
|
||||
fe-queries.h \
|
||||
hilight-text.h \
|
||||
keyboard.h \
|
||||
module-formats.h \
|
||||
|
@ -27,8 +27,6 @@
|
||||
#include "misc.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include "irc.h"
|
||||
#include "irc-channels.h"
|
||||
#include "channels-setup.h"
|
||||
#include "nicklist.h"
|
||||
|
||||
@ -70,22 +68,20 @@ static void signal_channel_destroyed(CHANNEL_REC *channel)
|
||||
|
||||
static void signal_window_item_removed(WINDOW_REC *window, WI_ITEM_REC *item)
|
||||
{
|
||||
IRC_CHANNEL_REC *channel;
|
||||
CHANNEL_REC *channel;
|
||||
|
||||
g_return_if_fail(window != NULL);
|
||||
|
||||
channel = IRC_CHANNEL(item);
|
||||
if (channel != NULL) channel_destroy(CHANNEL(channel));
|
||||
channel = CHANNEL(item);
|
||||
if (channel != NULL) channel_destroy(channel);
|
||||
}
|
||||
|
||||
static void sig_disconnected(IRC_SERVER_REC *server)
|
||||
static void sig_disconnected(SERVER_REC *server)
|
||||
{
|
||||
WINDOW_REC *window;
|
||||
GSList *tmp;
|
||||
|
||||
g_return_if_fail(server != NULL);
|
||||
if (!IS_IRC_SERVER(server))
|
||||
return;
|
||||
g_return_if_fail(IS_SERVER(server));
|
||||
|
||||
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
|
||||
CHANNEL_REC *channel = tmp->data;
|
||||
@ -101,7 +97,7 @@ static void signal_window_item_changed(WINDOW_REC *window, WI_ITEM_REC *item)
|
||||
g_return_if_fail(window != NULL);
|
||||
if (item == NULL) return;
|
||||
|
||||
if (g_slist_length(window->items) > 1 && IS_IRC_CHANNEL(item)) {
|
||||
if (g_slist_length(window->items) > 1 && IS_CHANNEL(item)) {
|
||||
printformat(item->server, item->name, MSGLEVEL_CLIENTNOTICE,
|
||||
IRCTXT_TALKING_IN, item->name);
|
||||
signal_stop();
|
||||
@ -146,7 +142,7 @@ static void cmd_wjoin_post(const char *data)
|
||||
|
||||
static void cmd_channel_list_joined(void)
|
||||
{
|
||||
IRC_CHANNEL_REC *channel;
|
||||
CHANNEL_REC *channel;
|
||||
GString *nicks;
|
||||
GSList *nicklist, *tmp, *ntmp;
|
||||
|
||||
@ -156,7 +152,7 @@ static void cmd_channel_list_joined(void)
|
||||
}
|
||||
|
||||
/* print active channel */
|
||||
channel = IRC_CHANNEL(active_win->active);
|
||||
channel = CHANNEL(active_win->active);
|
||||
if (channel != NULL)
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_CURRENT_CHANNEL, channel->name);
|
||||
|
||||
@ -165,7 +161,7 @@ static void cmd_channel_list_joined(void)
|
||||
for (tmp = channels; tmp != NULL; tmp = tmp->next) {
|
||||
channel = tmp->data;
|
||||
|
||||
nicklist = nicklist_getnicks(CHANNEL(channel));
|
||||
nicklist = nicklist_getnicks(channel);
|
||||
nicks = g_string_new(NULL);
|
||||
for (ntmp = nicklist; ntmp != NULL; ntmp = ntmp->next) {
|
||||
NICK_REC *rec = ntmp->data;
|
||||
@ -210,39 +206,37 @@ static void cmd_channel_list(void)
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_CHANSETUP_FOOTER);
|
||||
}
|
||||
|
||||
static void cmd_channel(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||
static void cmd_channel(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
||||
{
|
||||
if (*data == '\0')
|
||||
cmd_channel_list_joined();
|
||||
else if (ischannel(*data))
|
||||
signal_emit("command join", 2, data, server);
|
||||
else
|
||||
command_runsub("channel", data, server, item);
|
||||
}
|
||||
|
||||
/* SYNTAX: CHANNEL ADD [-auto | -noauto] [-bots <masks>] [-botcmd <command>]
|
||||
<channel> <ircnet> [<password>] */
|
||||
<channel> <chatnet> [<password>] */
|
||||
static void cmd_channel_add(const char *data)
|
||||
{
|
||||
GHashTable *optlist;
|
||||
CHANNEL_SETUP_REC *rec;
|
||||
char *botarg, *botcmdarg, *ircnet, *channel, *password;
|
||||
char *botarg, *botcmdarg, *chatnet, *channel, *password;
|
||||
void *free_arg;
|
||||
|
||||
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_OPTIONS,
|
||||
"channel add", &optlist, &channel, &ircnet, &password))
|
||||
"channel add", &optlist, &channel, &chatnet, &password))
|
||||
return;
|
||||
|
||||
botarg = g_hash_table_lookup(optlist, "bots");
|
||||
botcmdarg = g_hash_table_lookup(optlist, "botcmd");
|
||||
|
||||
if (*ircnet == '\0' || *channel == '\0')
|
||||
if (*chatnet == '\0' || *channel == '\0')
|
||||
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||
rec = channels_setup_find(channel, ircnet);
|
||||
rec = channels_setup_find(channel, chatnet);
|
||||
if (rec == NULL) {
|
||||
rec = g_new0(CHANNEL_SETUP_REC, 1);
|
||||
rec->name = g_strdup(channel);
|
||||
rec->chatnet = g_strdup(ircnet);
|
||||
rec->chatnet = g_strdup(chatnet);
|
||||
} else {
|
||||
if (g_hash_table_lookup(optlist, "bots")) g_free_and_null(rec->botmasks);
|
||||
if (g_hash_table_lookup(optlist, "botcmd")) g_free_and_null(rec->autosendcmd);
|
||||
@ -254,28 +248,28 @@ static void cmd_channel_add(const char *data)
|
||||
if (botcmdarg != NULL && *botcmdarg != '\0') rec->autosendcmd = g_strdup(botcmdarg);
|
||||
if (*password != '\0' && strcmp(password, "-") != 0) rec->password = g_strdup(password);
|
||||
channels_setup_create(rec);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_CHANSETUP_ADDED, channel, ircnet);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_CHANSETUP_ADDED, channel, chatnet);
|
||||
|
||||
cmd_params_free(free_arg);
|
||||
}
|
||||
|
||||
/* SYNTAX: CHANNEL REMOVE <channel> <ircnet> */
|
||||
/* SYNTAX: CHANNEL REMOVE <channel> <chatnet> */
|
||||
static void cmd_channel_remove(const char *data)
|
||||
{
|
||||
CHANNEL_SETUP_REC *rec;
|
||||
char *ircnet, *channel;
|
||||
char *chatnet, *channel;
|
||||
void *free_arg;
|
||||
|
||||
if (!cmd_get_params(data, &free_arg, 2, &channel, &ircnet))
|
||||
if (!cmd_get_params(data, &free_arg, 2, &channel, &chatnet))
|
||||
return;
|
||||
if (*ircnet == '\0' || *channel == '\0')
|
||||
if (*chatnet == '\0' || *channel == '\0')
|
||||
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||
|
||||
rec = channels_setup_find(channel, ircnet);
|
||||
rec = channels_setup_find(channel, chatnet);
|
||||
if (rec == NULL)
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_CHANSETUP_NOT_FOUND, channel, ircnet);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_CHANSETUP_NOT_FOUND, channel, chatnet);
|
||||
else {
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_CHANSETUP_REMOVED, channel, ircnet);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_CHANSETUP_REMOVED, channel, chatnet);
|
||||
channels_setup_destroy(rec);
|
||||
}
|
||||
cmd_params_free(free_arg);
|
@ -23,6 +23,7 @@
|
||||
#include "levels.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include "fe-queries.h"
|
||||
#include "hilight-text.h"
|
||||
#include "command-history.h"
|
||||
#include "completion.h"
|
||||
@ -39,6 +40,9 @@
|
||||
void autorun_init(void);
|
||||
void autorun_deinit(void);
|
||||
|
||||
void fe_channels_init(void);
|
||||
void fe_channels_deinit(void);
|
||||
|
||||
void fe_core_log_init(void);
|
||||
void fe_core_log_deinit(void);
|
||||
|
||||
@ -92,6 +96,8 @@ void fe_common_core_init(void)
|
||||
completion_init();
|
||||
keyboard_init();
|
||||
printtext_init();
|
||||
fe_channels_init();
|
||||
fe_queries_init();
|
||||
fe_log_init();
|
||||
fe_modules_init();
|
||||
fe_server_init();
|
||||
@ -113,6 +119,8 @@ void fe_common_core_deinit(void)
|
||||
completion_deinit();
|
||||
keyboard_deinit();
|
||||
printtext_deinit();
|
||||
fe_channels_deinit();
|
||||
fe_queries_deinit();
|
||||
fe_log_deinit();
|
||||
fe_modules_deinit();
|
||||
fe_server_deinit();
|
||||
|
@ -25,10 +25,8 @@
|
||||
#include "commands.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include "irc.h"
|
||||
#include "irc-commands.h"
|
||||
#include "levels.h"
|
||||
#include "irc-queries.h"
|
||||
#include "queries.h"
|
||||
|
||||
#include "windows.h"
|
||||
#include "window-items.h"
|
||||
@ -36,14 +34,17 @@
|
||||
static int queryclose_tag, query_auto_close;
|
||||
|
||||
/* Return query where to put the private message. */
|
||||
QUERY_REC *privmsg_get_query(IRC_SERVER_REC *server, const char *nick, int own)
|
||||
QUERY_REC *privmsg_get_query(SERVER_REC *server, const char *nick, int own)
|
||||
{
|
||||
QUERY_REC *query;
|
||||
|
||||
query = irc_query_find(server, nick);
|
||||
g_return_val_if_fail(IS_SERVER(server), NULL);
|
||||
g_return_val_if_fail(nick != NULL, NULL);
|
||||
|
||||
query = query_find(server, nick);
|
||||
if (query == NULL && settings_get_bool("autocreate_query") &&
|
||||
(!own || settings_get_bool("autocreate_own_query")))
|
||||
query = irc_query_create(server, nick, TRUE);
|
||||
query = query_create(server->chat_type, server, nick, TRUE);
|
||||
|
||||
return query;
|
||||
}
|
||||
@ -87,15 +88,15 @@ static void signal_window_item_removed(WINDOW_REC *window, WI_ITEM_REC *item)
|
||||
|
||||
g_return_if_fail(window != NULL);
|
||||
|
||||
query = IRC_QUERY(item);
|
||||
query = QUERY(item);
|
||||
if (query != NULL) query_destroy(query);
|
||||
}
|
||||
|
||||
static void sig_server_connected(IRC_SERVER_REC *server)
|
||||
static void sig_server_connected(SERVER_REC *server)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
if (!IS_IRC_SERVER(server))
|
||||
if (!IS_SERVER(server))
|
||||
return;
|
||||
|
||||
/* check if there's any queries without server */
|
||||
@ -117,20 +118,24 @@ static void cmd_window_server(const char *data)
|
||||
g_return_if_fail(data != NULL);
|
||||
|
||||
server = server_find_tag(data);
|
||||
if (IS_IRC_SERVER(server) && IS_IRC_QUERY(active_win->active)) {
|
||||
/* /WINDOW SERVER used in a query window */
|
||||
query_change_server((QUERY_REC *) active_win->active, server);
|
||||
window_change_server(active_win, server);
|
||||
if (!IS_SERVER(server) || !IS_QUERY(active_win->active))
|
||||
return;
|
||||
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_QUERY_SERVER_CHANGED, server->tag, server->connrec->address,
|
||||
server->connrec->chatnet == NULL ? "" : server->connrec->chatnet);
|
||||
/* /WINDOW SERVER used in a query window */
|
||||
query_change_server(QUERY(active_win->active), server);
|
||||
window_change_server(active_win, server);
|
||||
|
||||
signal_stop();
|
||||
}
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||
IRCTXT_QUERY_SERVER_CHANGED,
|
||||
server->tag, server->connrec->address,
|
||||
server->connrec->chatnet == NULL ? "" :
|
||||
server->connrec->chatnet);
|
||||
|
||||
signal_stop();
|
||||
}
|
||||
|
||||
/* SYNTAX: UNQUERY [<nick>] */
|
||||
static void cmd_unquery(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||
static void cmd_unquery(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
||||
{
|
||||
QUERY_REC *query;
|
||||
|
||||
@ -138,12 +143,13 @@ static void cmd_unquery(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *i
|
||||
|
||||
if (*data == '\0') {
|
||||
/* remove current query */
|
||||
query = IRC_QUERY(item);
|
||||
query = QUERY(item);
|
||||
if (query == NULL) return;
|
||||
} else {
|
||||
query = irc_query_find(server, data);
|
||||
query = query_find(server, data);
|
||||
if (query == NULL) {
|
||||
printformat(server, NULL, MSGLEVEL_CLIENTERROR, IRCTXT_NO_QUERY, data);
|
||||
printformat(server, NULL, MSGLEVEL_CLIENTERROR,
|
||||
IRCTXT_NO_QUERY, data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -152,7 +158,7 @@ static void cmd_unquery(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *i
|
||||
}
|
||||
|
||||
/* SYNTAX: QUERY [-window] <nick> */
|
||||
static void cmd_query(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||
static void cmd_query(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
||||
{
|
||||
GHashTable *optlist;
|
||||
WINDOW_REC *window;
|
||||
@ -173,7 +179,8 @@ static void cmd_query(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *ite
|
||||
"query", &optlist, &nick))
|
||||
return;
|
||||
if (*nick == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||
server = irccmd_options_get_server("query", optlist, server);
|
||||
|
||||
server = cmd_options_get_server("query", optlist, server);
|
||||
if (server == NULL) {
|
||||
cmd_params_free(free_arg);
|
||||
return;
|
||||
@ -187,9 +194,9 @@ static void cmd_query(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *ite
|
||||
(SIGNAL_FUNC) signal_query_created_curwin);
|
||||
}
|
||||
|
||||
query = irc_query_find(server, nick);
|
||||
query = query_find(server, nick);
|
||||
if (query == NULL)
|
||||
irc_query_create(server, nick, FALSE);
|
||||
query_create(server->chat_type, server, nick, FALSE);
|
||||
else {
|
||||
/* query already existed - change to query window */
|
||||
window = window_item_window((WI_ITEM_REC *) query);
|
||||
@ -214,7 +221,7 @@ static int window_has_query(WINDOW_REC *window)
|
||||
g_return_val_if_fail(window != NULL, FALSE);
|
||||
|
||||
for (tmp = window->items; tmp != NULL; tmp = tmp->next) {
|
||||
if (IS_IRC_QUERY(tmp->data))
|
||||
if (IS_QUERY(tmp->data))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -235,29 +242,6 @@ static void sig_window_changed(WINDOW_REC *window, WINDOW_REC *old_window)
|
||||
old_window->last_line = time(NULL);
|
||||
}
|
||||
|
||||
static void sig_window_restore_item(WINDOW_REC *window, const char *item)
|
||||
{
|
||||
IRC_SERVER_REC *server;
|
||||
QUERY_REC *rec;
|
||||
char *tag, *nick;
|
||||
|
||||
tag = g_strdup(item);
|
||||
nick = strchr(tag, ' ');
|
||||
if (nick == NULL || ischannel(*(nick+1))) {
|
||||
g_free(tag);
|
||||
return;
|
||||
}
|
||||
|
||||
server = (IRC_SERVER_REC *) server_find_tag(tag);
|
||||
|
||||
rec = irc_query_create(server, nick+1, TRUE);
|
||||
if (server == NULL)
|
||||
rec->server_tag = g_strdup(tag);
|
||||
|
||||
g_free(tag);
|
||||
signal_stop();
|
||||
}
|
||||
|
||||
static int sig_query_autoclose(void)
|
||||
{
|
||||
WINDOW_REC *window;
|
||||
@ -288,7 +272,7 @@ static void read_settings(void)
|
||||
}
|
||||
}
|
||||
|
||||
void fe_query_init(void)
|
||||
void fe_queries_init(void)
|
||||
{
|
||||
settings_add_bool("lookandfeel", "autocreate_query", TRUE);
|
||||
settings_add_bool("lookandfeel", "autocreate_own_query", TRUE);
|
||||
@ -302,7 +286,6 @@ void fe_query_init(void)
|
||||
signal_add("window item remove", (SIGNAL_FUNC) signal_window_item_removed);
|
||||
signal_add("server connected", (SIGNAL_FUNC) sig_server_connected);
|
||||
signal_add("window changed", (SIGNAL_FUNC) sig_window_changed);
|
||||
signal_add("window restore item", (SIGNAL_FUNC) sig_window_restore_item);
|
||||
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
|
||||
|
||||
command_bind("query", NULL, (SIGNAL_FUNC) cmd_query);
|
||||
@ -312,7 +295,7 @@ void fe_query_init(void)
|
||||
command_set_options("query", "window");
|
||||
}
|
||||
|
||||
void fe_query_deinit(void)
|
||||
void fe_queries_deinit(void)
|
||||
{
|
||||
if (queryclose_tag != -1) g_source_remove(queryclose_tag);
|
||||
|
||||
@ -321,7 +304,6 @@ void fe_query_deinit(void)
|
||||
signal_remove("window item remove", (SIGNAL_FUNC) signal_window_item_removed);
|
||||
signal_remove("server connected", (SIGNAL_FUNC) sig_server_connected);
|
||||
signal_remove("window changed", (SIGNAL_FUNC) sig_window_changed);
|
||||
signal_remove("window restore item", (SIGNAL_FUNC) sig_window_restore_item);
|
||||
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
||||
|
||||
command_unbind("query", (SIGNAL_FUNC) cmd_query);
|
12
src/fe-common/core/fe-queries.h
Normal file
12
src/fe-common/core/fe-queries.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef __FE_QUERIES_H
|
||||
#define __FE_QUERIES_H
|
||||
|
||||
#include "queries.h"
|
||||
|
||||
/* Return query where to put the private message. */
|
||||
QUERY_REC *privmsg_get_query(SERVER_REC *server, const char *nick, int own);
|
||||
|
||||
void fe_queries_init(void);
|
||||
void fe_queries_deinit(void);
|
||||
|
||||
#endif
|
@ -50,6 +50,28 @@ FORMAT_REC fecommon_core_formats[] = {
|
||||
{ "server_changed", "Changed to %_$2%_ server %_$1%_", 3, { 0, 0, 0 } },
|
||||
{ "unknown_server_tag", "Unknown server tag %_$0%_", 1, { 0 } },
|
||||
|
||||
/* ---- */
|
||||
{ NULL, "Channels", 0 },
|
||||
|
||||
{ "talking_in", "You are now talking in %_$0%_", 1, { 0 } },
|
||||
{ "not_in_channels", "You are not on any channels", 0 },
|
||||
{ "current_channel", "Current channel $0", 1, { 0 } },
|
||||
{ "chanlist_header", "You are on the following channels:", 0 },
|
||||
{ "chanlist_line", "$[-10]0 %|+$1 ($2): $3", 4, { 0, 0, 0, 0 } },
|
||||
{ "chansetup_not_found", "Channel $0 not found", 2, { 0, 0 } },
|
||||
{ "chansetup_added", "Channel $0 saved", 2, { 0, 0 } },
|
||||
{ "chansetup_removed", "Channel $0 removed", 2, { 0, 0 } },
|
||||
{ "chansetup_header", "Channel IRC net Password Settings", 0 },
|
||||
{ "chansetup_line", "$[15]0 %|$[10]1 $[10]2 $3", 4, { 0, 0, 0, 0 } },
|
||||
{ "chansetup_footer", "", 0 },
|
||||
|
||||
/* ---- */
|
||||
{ NULL, "Queries", 0 },
|
||||
|
||||
{ "query_start", "Starting query with %_$0%_", 1, { 0 } },
|
||||
{ "no_query", "No query with %_$0%_", 1, { 0 } },
|
||||
{ "query_server_changed", "Query with %_$2%_ changed to server %_$1%_", 3, { 0, 0, 0 } },
|
||||
|
||||
/* ---- */
|
||||
{ NULL, "Highlighting", 0 },
|
||||
|
||||
|
@ -29,13 +29,33 @@ enum {
|
||||
|
||||
IRCTXT_FILL_3,
|
||||
|
||||
IRCTXT_TALKING_IN,
|
||||
IRCTXT_NOT_IN_CHANNELS,
|
||||
IRCTXT_CURRENT_CHANNEL,
|
||||
IRCTXT_CHANLIST_HEADER,
|
||||
IRCTXT_CHANLIST_LINE,
|
||||
IRCTXT_CHANSETUP_NOT_FOUND,
|
||||
IRCTXT_CHANSETUP_ADDED,
|
||||
IRCTXT_CHANSETUP_REMOVED,
|
||||
IRCTXT_CHANSETUP_HEADER,
|
||||
IRCTXT_CHANSETUP_LINE,
|
||||
IRCTXT_CHANSETUP_FOOTER,
|
||||
|
||||
IRCTXT_FILL_4,
|
||||
|
||||
IRCTXT_QUERY_STARTED,
|
||||
IRCTXT_NO_QUERY,
|
||||
IRCTXT_QUERY_SERVER_CHANGED,
|
||||
|
||||
IRCTXT_FILL_5,
|
||||
|
||||
IRCTXT_HILIGHT_HEADER,
|
||||
IRCTXT_HILIGHT_LINE,
|
||||
IRCTXT_HILIGHT_FOOTER,
|
||||
IRCTXT_HILIGHT_NOT_FOUND,
|
||||
IRCTXT_HILIGHT_REMOVED,
|
||||
|
||||
IRCTXT_FILL_4,
|
||||
IRCTXT_FILL_6,
|
||||
|
||||
IRCTXT_ALIAS_ADDED,
|
||||
IRCTXT_ALIAS_REMOVED,
|
||||
@ -44,7 +64,7 @@ enum {
|
||||
IRCTXT_ALIASLIST_LINE,
|
||||
IRCTXT_ALIASLIST_FOOTER,
|
||||
|
||||
IRCTXT_FILL_5,
|
||||
IRCTXT_FILL_7,
|
||||
|
||||
IRCTXT_LOG_OPENED,
|
||||
IRCTXT_LOG_CLOSED,
|
||||
@ -61,7 +81,7 @@ enum {
|
||||
IRCTXT_LOG_NO_AWAY_MSGS,
|
||||
IRCTXT_LOG_AWAY_MSGS,
|
||||
|
||||
IRCTXT_FILL_6,
|
||||
IRCTXT_FILL_8,
|
||||
|
||||
IRCTXT_MODULE_ALREADY_LOADED,
|
||||
IRCTXT_MODULE_LOAD_ERROR,
|
||||
@ -69,7 +89,7 @@ enum {
|
||||
IRCTXT_MODULE_LOADED,
|
||||
IRCTXT_MODULE_UNLOADED,
|
||||
|
||||
IRCTXT_FILL_7,
|
||||
IRCTXT_FILL_9,
|
||||
|
||||
IRCTXT_COMMAND_UNKNOWN,
|
||||
IRCTXT_COMMAND_AMBIGUOUS,
|
||||
@ -83,7 +103,7 @@ enum {
|
||||
IRCTXT_CHAN_NOT_SYNCED,
|
||||
IRCTXT_NOT_GOOD_IDEA,
|
||||
|
||||
IRCTXT_FILL_8,
|
||||
IRCTXT_FILL_10,
|
||||
|
||||
IRCTXT_THEME_SAVED,
|
||||
IRCTXT_THEME_SAVE_FAILED,
|
||||
@ -93,7 +113,7 @@ enum {
|
||||
IRCTXT_FORMAT_SUBTITLE,
|
||||
IRCTXT_FORMAT_ITEM,
|
||||
|
||||
IRCTXT_FILL_9,
|
||||
IRCTXT_FILL_11,
|
||||
|
||||
IRCTXT_NOT_TOGGLE,
|
||||
IRCTXT_PERL_ERROR,
|
||||
|
@ -21,25 +21,55 @@
|
||||
#include "module.h"
|
||||
#include "signals.h"
|
||||
#include "misc.h"
|
||||
#include "servers.h"
|
||||
#include "levels.h"
|
||||
#include "lib-config/iconfig.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include "levels.h"
|
||||
#include "chat-protocols.h"
|
||||
#include "servers.h"
|
||||
#include "queries.h"
|
||||
|
||||
#include "themes.h"
|
||||
#include "windows.h"
|
||||
#include "window-items.h"
|
||||
|
||||
static void sig_window_restore_item(WINDOW_REC *window, const char *item)
|
||||
static void sig_window_restore_item(WINDOW_REC *window, const char *type,
|
||||
CONFIG_NODE *node)
|
||||
{
|
||||
window->waiting_channels =
|
||||
g_slist_append(window->waiting_channels, g_strdup(item));
|
||||
char *name, *tag, *chat_type, *str;
|
||||
|
||||
chat_type = config_node_get_str(node, "chat_type", NULL);
|
||||
name = config_node_get_str(node, "name", NULL);
|
||||
tag = config_node_get_str(node, "tag", NULL);
|
||||
if (name == NULL) return;
|
||||
|
||||
if (g_strcasecmp(type, "CHANNEL") == 0) {
|
||||
/* add channel to "waiting channels" list */
|
||||
str = tag == NULL ? g_strdup(name) :
|
||||
g_strdup_printf("%s %s", tag, name);
|
||||
|
||||
window->waiting_channels =
|
||||
g_slist_append(window->waiting_channels, str);
|
||||
} else if (g_strcasecmp(type, "QUERY") == 0) {
|
||||
/* create query immediately */
|
||||
QUERY_REC *query;
|
||||
SERVER_REC *server;
|
||||
|
||||
if (chat_type == NULL)
|
||||
return;
|
||||
|
||||
server = tag == NULL ? NULL : server_find_tag(tag);
|
||||
query = query_create(chat_protocol_lookup(chat_type),
|
||||
server, name, TRUE);
|
||||
if (server == NULL && tag != NULL)
|
||||
query->server_tag = g_strdup(tag);
|
||||
}
|
||||
}
|
||||
|
||||
static void window_add_items(WINDOW_REC *window, CONFIG_NODE *node)
|
||||
{
|
||||
GSList *tmp;
|
||||
char *type;
|
||||
|
||||
if (node == NULL)
|
||||
return;
|
||||
@ -47,7 +77,11 @@ static void window_add_items(WINDOW_REC *window, CONFIG_NODE *node)
|
||||
for (tmp = node->value; tmp != NULL; tmp = tmp->next) {
|
||||
CONFIG_NODE *node = tmp->data;
|
||||
|
||||
signal_emit("window restore item", 2, window, node->value);
|
||||
type = config_node_get_str(node->value, "type", NULL);
|
||||
if (type != NULL) {
|
||||
signal_emit("window restore item", 3,
|
||||
window, type, node->value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,21 +115,27 @@ void windows_restore(void)
|
||||
|
||||
static void window_save_items(WINDOW_REC *window, CONFIG_NODE *node)
|
||||
{
|
||||
CONFIG_NODE *subnode;
|
||||
GSList *tmp;
|
||||
char *str;
|
||||
const char *type;
|
||||
|
||||
node = config_node_section(node, "items", NODE_TYPE_LIST);
|
||||
for (tmp = window->items; tmp != NULL; tmp = tmp->next) {
|
||||
WI_ITEM_REC *rec = tmp->data;
|
||||
SERVER_REC *server = rec->server;
|
||||
|
||||
if (server == NULL)
|
||||
iconfig_node_set_str(node, NULL, rec->name);
|
||||
else {
|
||||
str = g_strdup_printf("%s %s", server->tag, rec->name);
|
||||
iconfig_node_set_str(node, NULL, str);
|
||||
g_free(str);
|
||||
}
|
||||
type = module_find_id_str("WINDOW ITEM TYPE", rec->type);
|
||||
if (type == NULL) continue;
|
||||
|
||||
subnode = config_node_section(node, NULL, NODE_TYPE_BLOCK);
|
||||
|
||||
iconfig_node_set_str(subnode, "type", type);
|
||||
iconfig_node_set_str(subnode, "chat_type",
|
||||
chat_protocol_get_name(rec->chat_type));
|
||||
iconfig_node_set_str(subnode, "name", rec->name);
|
||||
|
||||
if (server != NULL)
|
||||
iconfig_node_set_str(subnode, "tag", server->tag);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ INCLUDES = \
|
||||
-DSYSCONFDIR=\""$(sysconfdir)"\"
|
||||
|
||||
libfe_common_irc_a_SOURCES = \
|
||||
fe-channels.c \
|
||||
fe-irc-channels.c \
|
||||
fe-irc-commands.c \
|
||||
fe-irc-server.c \
|
||||
fe-ircnet.c \
|
||||
@ -22,7 +22,6 @@ libfe_common_irc_a_SOURCES = \
|
||||
fe-ignore.c \
|
||||
fe-netjoin.c \
|
||||
fe-netsplit.c \
|
||||
fe-queries.c \
|
||||
fe-common-irc.c \
|
||||
irc-completion.c \
|
||||
irc-window-activity.c \
|
||||
@ -32,7 +31,6 @@ libfe_common_irc_a_SOURCES = \
|
||||
|
||||
noinst_HEADERS = \
|
||||
fe-common-irc.h \
|
||||
fe-queries.h \
|
||||
irc-hilight-text.h \
|
||||
module.h \
|
||||
module-formats.h
|
||||
|
@ -34,8 +34,8 @@
|
||||
void fe_irc_modules_init(void);
|
||||
void fe_irc_modules_deinit(void);
|
||||
|
||||
void fe_channels_init(void);
|
||||
void fe_channels_deinit(void);
|
||||
void fe_irc_channels_init(void);
|
||||
void fe_irc_channels_deinit(void);
|
||||
|
||||
void fe_irc_commands_init(void);
|
||||
void fe_irc_commands_deinit(void);
|
||||
@ -58,9 +58,6 @@ void fe_events_numeric_deinit(void);
|
||||
void fe_ignore_init(void);
|
||||
void fe_ignore_deinit(void);
|
||||
|
||||
void fe_query_init(void);
|
||||
void fe_query_deinit(void);
|
||||
|
||||
void irc_completion_init(void);
|
||||
void irc_completion_deinit(void);
|
||||
|
||||
@ -109,7 +106,7 @@ void fe_common_irc_init(void)
|
||||
|
||||
theme_register(fecommon_irc_formats);
|
||||
|
||||
fe_channels_init();
|
||||
fe_irc_channels_init();
|
||||
fe_irc_commands_init();
|
||||
fe_ircnet_init();
|
||||
fe_irc_server_init();
|
||||
@ -119,7 +116,6 @@ void fe_common_irc_init(void)
|
||||
fe_ignore_init();
|
||||
fe_netsplit_init();
|
||||
fe_netjoin_init();
|
||||
fe_query_init();
|
||||
irc_completion_init();
|
||||
irc_hilight_text_init();
|
||||
irc_window_activity_init();
|
||||
@ -131,7 +127,7 @@ void fe_common_irc_deinit(void)
|
||||
{
|
||||
fe_irc_modules_deinit();
|
||||
|
||||
fe_channels_deinit();
|
||||
fe_irc_channels_deinit();
|
||||
fe_irc_commands_deinit();
|
||||
fe_ircnet_deinit();
|
||||
fe_irc_server_deinit();
|
||||
@ -141,7 +137,6 @@ void fe_common_irc_deinit(void)
|
||||
fe_ignore_deinit();
|
||||
fe_netsplit_deinit();
|
||||
fe_netjoin_deinit();
|
||||
fe_query_deinit();
|
||||
irc_completion_deinit();
|
||||
irc_hilight_text_deinit();
|
||||
irc_window_activity_deinit();
|
||||
|
@ -113,7 +113,7 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *
|
||||
print_channel_msg(server, msg, nick, addr, target);
|
||||
} else {
|
||||
/* private message */
|
||||
item = (WI_ITEM_REC *) privmsg_get_query(server, nick, FALSE);
|
||||
item = (WI_ITEM_REC *) privmsg_get_query(SERVER(server), nick, FALSE);
|
||||
printformat(server, nick, MSGLEVEL_MSGS,
|
||||
item == NULL ? IRCTXT_MSG_PRIVATE : IRCTXT_MSG_PRIVATE_QUERY, nick, addr, msg);
|
||||
}
|
||||
@ -156,7 +156,7 @@ static void ctcp_msg_check_action(const char *data, IRC_SERVER_REC *server,
|
||||
}
|
||||
} else {
|
||||
/* private action */
|
||||
item = (WI_ITEM_REC *) privmsg_get_query(server, nick, FALSE);
|
||||
item = (WI_ITEM_REC *) privmsg_get_query(SERVER(server), nick, FALSE);
|
||||
printformat(server, nick, level,
|
||||
item == NULL ? IRCTXT_ACTION_PRIVATE : IRCTXT_ACTION_PRIVATE_QUERY,
|
||||
nick, addr == NULL ? "" : addr, data);
|
||||
|
44
src/fe-common/irc/fe-irc-channels.c
Normal file
44
src/fe-common/irc/fe-irc-channels.c
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
fe-irc-channels.c : irssi
|
||||
|
||||
Copyright (C) 1999-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 "signals.h"
|
||||
#include "commands.h"
|
||||
#include "servers.h"
|
||||
|
||||
#include "irc.h"
|
||||
|
||||
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)
|
||||
{
|
||||
command_bind("channel", NULL, (SIGNAL_FUNC) cmd_channel);
|
||||
}
|
||||
|
||||
void fe_irc_channels_deinit(void)
|
||||
{
|
||||
command_unbind("channel", (SIGNAL_FUNC) cmd_channel);
|
||||
}
|
@ -27,7 +27,6 @@
|
||||
|
||||
#include "levels.h"
|
||||
#include "irc.h"
|
||||
#include "irc-commands.h"
|
||||
#include "servers.h"
|
||||
#include "mode-lists.h"
|
||||
#include "nicklist.h"
|
||||
@ -56,7 +55,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("msg", optlist, server);
|
||||
server = IRC_SERVER(cmd_options_get_server("msg", optlist, SERVER(server)));
|
||||
|
||||
if (*target == '=')
|
||||
{
|
||||
@ -119,7 +118,7 @@ static void cmd_msg(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||
else
|
||||
{
|
||||
/* private message */
|
||||
item = (WI_ITEM_REC *) privmsg_get_query(server, target, TRUE);
|
||||
item = (WI_ITEM_REC *) privmsg_get_query(SERVER(server), target, TRUE);
|
||||
printformat(server, target, MSGLEVEL_MSGS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
||||
item == NULL ? IRCTXT_OWN_MSG_PRIVATE : IRCTXT_OWN_MSG_PRIVATE_QUERY, target, msg, server->nick);
|
||||
}
|
||||
|
@ -1,7 +0,0 @@
|
||||
#ifndef __FE_QUERIES_H
|
||||
#define __FE_QUERIES_H
|
||||
|
||||
/* Return query where to put the private message. */
|
||||
QUERY_REC *privmsg_get_query(IRC_SERVER_REC *server, const char *nick, int own);
|
||||
|
||||
#endif
|
@ -26,7 +26,6 @@
|
||||
#include "settings.h"
|
||||
|
||||
#include "irc.h"
|
||||
#include "irc-commands.h"
|
||||
#include "servers.h"
|
||||
#include "irc-channels.h"
|
||||
#include "irc-queries.h"
|
||||
@ -260,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("msg", optlist, server);
|
||||
server = IRC_SERVER(cmd_options_get_server("msg", optlist, SERVER(server)));
|
||||
|
||||
if (*target != '\0' && *msg != '\0') {
|
||||
if (!ischannel(*target) && *target != '=' && server != NULL)
|
||||
|
@ -34,7 +34,6 @@ FORMAT_REC fecommon_irc_formats[] = {
|
||||
{ "server_reconnect_list", "%_$0%_: $1:$2 ($3) ($5 left before reconnecting)", 6, { 0, 0, 1, 0, 0, 0 } },
|
||||
{ "server_reconnect_removed", "Removed reconnection to server %_$0%_ port %_$1%_", 3, { 0, 1, 0 } },
|
||||
{ "server_reconnect_not_found", "Reconnection tag %_$0%_ not found", 1, { 0 } },
|
||||
{ "query_server_changed", "Query with %_$2%_ changed to server %_$1%_", 3, { 0, 0, 0 } },
|
||||
{ "setupserver_added", "Server $0 saved", 2, { 0, 1 } },
|
||||
{ "setupserver_removed", "Server $0 removed", 2, { 0, 1 } },
|
||||
{ "setupserver_not_found", "Server $0 not found", 2, { 0, 1 } },
|
||||
@ -95,16 +94,6 @@ FORMAT_REC fecommon_irc_formats[] = {
|
||||
{ "invitelist", "%_$0%_: invite %c$1", 2, { 0, 0 } },
|
||||
{ "no_such_channel", "$0: No such channel", 1, { 0 } },
|
||||
{ "channel_synced", "Join to %_$0%_ was synced in %_$1%_ secs", 2, { 0, 2 } },
|
||||
{ "not_in_channels", "You are not on any channels", 0 },
|
||||
{ "current_channel", "Current channel $0", 1, { 0 } },
|
||||
{ "chanlist_header", "You are on the following channels:", 0 },
|
||||
{ "chanlist_line", "$[-10]0 %|+$1 ($2): $3", 4, { 0, 0, 0, 0 } },
|
||||
{ "chansetup_not_found", "Channel $0 not found", 2, { 0, 0 } },
|
||||
{ "chansetup_added", "Channel $0 saved", 2, { 0, 0 } },
|
||||
{ "chansetup_removed", "Channel $0 removed", 2, { 0, 0 } },
|
||||
{ "chansetup_header", "Channel IRC net Password Settings", 0 },
|
||||
{ "chansetup_line", "$[15]0 %|$[10]1 $[10]2 $3", 4, { 0, 0, 0, 0 } },
|
||||
{ "chansetup_footer", "", 0 },
|
||||
|
||||
/* ---- */
|
||||
{ NULL, "Nick", 0 },
|
||||
@ -201,9 +190,6 @@ FORMAT_REC fecommon_irc_formats[] = {
|
||||
{ "ignore_header", "Ignorance List:", 0 },
|
||||
{ "ignore_line", "$[-4]0 $1: $2 $3 $4", 4, { 1, 0, 0, 0 } },
|
||||
{ "ignore_footer", "", 0 },
|
||||
{ "talking_in", "You are now talking in %_$0%_", 1, { 0 } },
|
||||
{ "query_start", "Starting query with %_$0%_", 1, { 0 } },
|
||||
{ "no_query", "No query with %_$0%_", 1, { 0 } },
|
||||
{ "no_msgs_got", "You have not received a message from anyone yet", 0 },
|
||||
{ "no_msgs_sent", "You have not sent a message to anyone yet", 0 },
|
||||
|
||||
|
@ -12,7 +12,6 @@ enum {
|
||||
IRCTXT_SERVER_RECONNECT_LIST,
|
||||
IRCTXT_RECONNECT_REMOVED,
|
||||
IRCTXT_RECONNECT_NOT_FOUND,
|
||||
IRCTXT_QUERY_SERVER_CHANGED,
|
||||
IRCTXT_SETUPSERVER_ADDED,
|
||||
IRCTXT_SETUPSERVER_REMOVED,
|
||||
IRCTXT_SETUPSERVER_NOT_FOUND,
|
||||
@ -72,16 +71,6 @@ enum {
|
||||
IRCTXT_INVITELIST,
|
||||
IRCTXT_NO_SUCH_CHANNEL,
|
||||
IRCTXT_CHANNEL_SYNCED,
|
||||
IRCTXT_NOT_IN_CHANNELS,
|
||||
IRCTXT_CURRENT_CHANNEL,
|
||||
IRCTXT_CHANLIST_HEADER,
|
||||
IRCTXT_CHANLIST_LINE,
|
||||
IRCTXT_CHANSETUP_NOT_FOUND,
|
||||
IRCTXT_CHANSETUP_ADDED,
|
||||
IRCTXT_CHANSETUP_REMOVED,
|
||||
IRCTXT_CHANSETUP_HEADER,
|
||||
IRCTXT_CHANSETUP_LINE,
|
||||
IRCTXT_CHANSETUP_FOOTER,
|
||||
|
||||
IRCTXT_FILL_4,
|
||||
|
||||
@ -171,9 +160,6 @@ enum {
|
||||
IRCTXT_IGNORE_HEADER,
|
||||
IRCTXT_IGNORE_LINE,
|
||||
IRCTXT_IGNORE_FOOTER,
|
||||
IRCTXT_TALKING_IN,
|
||||
IRCTXT_QUERY_STARTED,
|
||||
IRCTXT_NO_QUERY,
|
||||
IRCTXT_NO_MSGS_GOT,
|
||||
IRCTXT_NO_MSGS_SENT
|
||||
};
|
||||
|
@ -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…
Reference in New Issue
Block a user