mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Moved nick/msg/channel completion to core with some cleanups.
Moved ignore checking to fe-ignore-messages.c. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@750 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
8c4b167327
commit
98060c3185
@ -19,3 +19,6 @@ int joined:1; /* Have we even received JOIN event for this channel? */
|
||||
int left:1; /* You just left the channel */
|
||||
int kicked:1; /* You just got kicked */
|
||||
int destroying:1;
|
||||
|
||||
GSList *lastmsgs; /* List of nicks who last send message */
|
||||
GSList *lastownmsgs; /* List of nicks who last send message to you */
|
||||
|
@ -41,6 +41,8 @@ time_t lag_sent; /* 0 or time when last lag query was sent to server */
|
||||
time_t lag_last_check; /* last time we checked lag */
|
||||
int lag; /* server lag in milliseconds */
|
||||
|
||||
GSList *lastmsgs; /* List of nicks who last send you msg */
|
||||
|
||||
GSList *channels;
|
||||
GSList *queries;
|
||||
|
||||
|
@ -32,6 +32,11 @@ typedef struct {
|
||||
#include "server-rec.h"
|
||||
} SERVER_REC;
|
||||
|
||||
typedef struct {
|
||||
time_t time;
|
||||
char *nick;
|
||||
} LAST_MSG_REC;
|
||||
|
||||
extern GSList *servers, *lookup_servers;
|
||||
|
||||
void servers_init(void);
|
||||
|
@ -8,12 +8,14 @@ INCLUDES = \
|
||||
|
||||
libfe_common_core_a_SOURCES = \
|
||||
autorun.c \
|
||||
chat-completion.c \
|
||||
command-history.c \
|
||||
completion.c \
|
||||
fe-channels.c \
|
||||
fe-common-core.c \
|
||||
fe-core-commands.c \
|
||||
fe-ignore.c \
|
||||
fe-ignore-messages.c \
|
||||
fe-log.c \
|
||||
fe-messages.c \
|
||||
fe-modules.c \
|
||||
|
651
src/fe-common/core/chat-completion.c
Normal file
651
src/fe-common/core/chat-completion.c
Normal file
@ -0,0 +1,651 @@
|
||||
/*
|
||||
chat-completion.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 "misc.h"
|
||||
#include "lib-config/iconfig.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include "servers.h"
|
||||
#include "channels.h"
|
||||
#include "channels-setup.h"
|
||||
#include "queries.h"
|
||||
#include "nicklist.h"
|
||||
|
||||
#include "completion.h"
|
||||
#include "window-items.h"
|
||||
|
||||
static int complete_tag;
|
||||
|
||||
#define SERVER_LAST_MSG_ADD(server, nick) \
|
||||
last_msg_add(&server->lastmsgs, nick)
|
||||
#define SERVER_LAST_MSG_DESTROY(server, nick) \
|
||||
last_msg_destroy(&server->lastmsgs, nick)
|
||||
|
||||
static LAST_MSG_REC *last_msg_find(GSList *list, const char *nick)
|
||||
{
|
||||
while (list != NULL) {
|
||||
LAST_MSG_REC *rec = list->data;
|
||||
|
||||
if (g_strcasecmp(rec->nick, nick) == 0)
|
||||
return rec;
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void last_msg_add(GSList **list, const char *nick)
|
||||
{
|
||||
LAST_MSG_REC *rec;
|
||||
|
||||
rec = last_msg_find(*list, nick);
|
||||
if (rec != NULL) {
|
||||
/* msg already exists, update it */
|
||||
*list = g_slist_remove(*list, rec);
|
||||
} else {
|
||||
rec = g_new(LAST_MSG_REC, 1);
|
||||
rec->nick = g_strdup(nick);
|
||||
}
|
||||
rec->time = time(NULL);
|
||||
|
||||
*list = g_slist_prepend(*list, rec);
|
||||
}
|
||||
|
||||
static void last_msg_destroy(GSList **list, LAST_MSG_REC *rec)
|
||||
{
|
||||
*list = g_slist_remove(*list, rec);
|
||||
|
||||
g_free(rec->nick);
|
||||
g_free(rec);
|
||||
}
|
||||
|
||||
static void last_msgs_remove_old(GSList **list, int timeout, time_t now)
|
||||
{
|
||||
GSList *tmp, *next;
|
||||
|
||||
for (tmp = *list; tmp != NULL; tmp = next) {
|
||||
LAST_MSG_REC *rec = tmp->data;
|
||||
|
||||
next = tmp->next;
|
||||
if (now-rec->time > timeout)
|
||||
last_msg_destroy(list, rec);
|
||||
}
|
||||
}
|
||||
|
||||
static int last_msg_cmp(LAST_MSG_REC *m1, LAST_MSG_REC *m2)
|
||||
{
|
||||
return m1->time < m2->time ? 1 : -1;
|
||||
}
|
||||
|
||||
static int nick_completion_timeout(void)
|
||||
{
|
||||
GSList *tmp;
|
||||
time_t now;
|
||||
int len, keep_private_count;
|
||||
int keep_msgs_time, keep_msgs_count, keep_ownmsgs_time;
|
||||
|
||||
keep_private_count = settings_get_int("completion_keep_privates");
|
||||
|
||||
now = time(NULL);
|
||||
for (tmp = servers; tmp != NULL; tmp = tmp->next) {
|
||||
SERVER_REC *server = tmp->data;
|
||||
|
||||
len = g_slist_length(server->lastmsgs);
|
||||
if (len > 0 && len >= keep_private_count) {
|
||||
/* remove the oldest msg nick. */
|
||||
GSList *link = g_slist_last(server->lastmsgs);
|
||||
SERVER_LAST_MSG_DESTROY(server, link->data);
|
||||
}
|
||||
}
|
||||
|
||||
keep_ownmsgs_time = settings_get_int("completion_keep_ownpublics");
|
||||
keep_msgs_time = settings_get_int("completion_keep_publics");
|
||||
keep_msgs_count = settings_get_int("completion_keep_publics_count");
|
||||
|
||||
for (tmp = channels; tmp != NULL; tmp = tmp->next) {
|
||||
CHANNEL_REC *channel = tmp->data;
|
||||
|
||||
last_msgs_remove_old(&channel->lastmsgs, keep_msgs_time, now);
|
||||
|
||||
if (keep_msgs_count == 0 ||
|
||||
g_slist_length(channel->lastownmsgs) > keep_msgs_count) {
|
||||
last_msgs_remove_old(&channel->lastownmsgs,
|
||||
keep_ownmsgs_time, now);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void sig_message_public(SERVER_REC *server, const char *msg,
|
||||
const char *nick, const char *address,
|
||||
const char *target)
|
||||
{
|
||||
CHANNEL_REC *channel;
|
||||
GSList **list;
|
||||
|
||||
channel = channel_find(server, target);
|
||||
if (channel != NULL) {
|
||||
list = nick_match_msg(server, msg, server->nick) ?
|
||||
&channel->lastownmsgs :
|
||||
&channel->lastmsgs;
|
||||
last_msg_add(list, nick);
|
||||
}
|
||||
}
|
||||
|
||||
static void sig_message_private(SERVER_REC *server, const char *msg,
|
||||
const char *nick, const char *address)
|
||||
{
|
||||
SERVER_LAST_MSG_ADD(server, nick);
|
||||
}
|
||||
|
||||
static void cmd_msg(const char *data, SERVER_REC *server)
|
||||
{
|
||||
GHashTable *optlist;
|
||||
char *target, *msg;
|
||||
void *free_arg;
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
|
||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS |
|
||||
PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
|
||||
"msg", &optlist, &target, &msg))
|
||||
return;
|
||||
server = cmd_options_get_server("msg", optlist, server);
|
||||
|
||||
if (*target != '\0' && *msg != '\0' && *target != '=' &&
|
||||
server != NULL && !server->ischannel(*target))
|
||||
SERVER_LAST_MSG_ADD(server, target);
|
||||
|
||||
cmd_params_free(free_arg);
|
||||
}
|
||||
|
||||
static void sig_nick_removed(CHANNEL_REC *channel, NICK_REC *nick)
|
||||
{
|
||||
LAST_MSG_REC *rec;
|
||||
|
||||
rec = last_msg_find(channel->lastownmsgs, nick->nick);
|
||||
if (rec != NULL) last_msg_destroy(&channel->lastownmsgs, rec);
|
||||
|
||||
rec = last_msg_find(channel->lastmsgs, nick->nick);
|
||||
if (rec != NULL) last_msg_destroy(&channel->lastmsgs, rec);
|
||||
}
|
||||
|
||||
static void sig_nick_changed(CHANNEL_REC *channel, NICK_REC *nick,
|
||||
const char *oldnick)
|
||||
{
|
||||
LAST_MSG_REC *rec;
|
||||
|
||||
rec = last_msg_find(channel->lastownmsgs, oldnick);
|
||||
if (rec != NULL) {
|
||||
g_free(rec->nick);
|
||||
rec->nick = g_strdup(nick->nick);
|
||||
}
|
||||
|
||||
rec = last_msg_find(channel->lastmsgs, oldnick);
|
||||
if (rec != NULL) {
|
||||
g_free(rec->nick);
|
||||
rec->nick = g_strdup(nick->nick);
|
||||
}
|
||||
}
|
||||
|
||||
/* Complete /MSG from specified server */
|
||||
static void completion_msg_server(GSList **list, SERVER_REC *server,
|
||||
const char *nick, const char *prefix)
|
||||
{
|
||||
LAST_MSG_REC *msg;
|
||||
GSList *tmp;
|
||||
int len;
|
||||
|
||||
g_return_if_fail(nick != NULL);
|
||||
|
||||
len = strlen(nick);
|
||||
for (tmp = server->lastmsgs; tmp != NULL; tmp = tmp->next) {
|
||||
LAST_MSG_REC *rec = tmp->data;
|
||||
|
||||
if (len != 0 && g_strncasecmp(rec->nick, nick, len) != 0)
|
||||
continue;
|
||||
|
||||
msg = g_new(LAST_MSG_REC, 1);
|
||||
msg->time = rec->time;
|
||||
msg->nick = prefix == NULL || *prefix == '\0' ?
|
||||
g_strdup(rec->nick) :
|
||||
g_strconcat(prefix, " ", rec->nick, NULL);
|
||||
*list = g_slist_insert_sorted(*list, msg,
|
||||
(GCompareFunc) last_msg_cmp);
|
||||
}
|
||||
}
|
||||
|
||||
/* convert list of LAST_MSG_REC's to list of char* nicks. */
|
||||
static GList *convert_msglist(GSList *msglist)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
list = NULL;
|
||||
while (msglist != NULL) {
|
||||
LAST_MSG_REC *rec = msglist->data;
|
||||
|
||||
list = g_list_append(list, rec->nick);
|
||||
msglist = g_slist_remove(msglist, rec);
|
||||
g_free(rec);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/* Complete /MSG - if `find_server' is NULL, complete nicks from all servers */
|
||||
static GList *completion_msg(SERVER_REC *win_server,
|
||||
SERVER_REC *find_server,
|
||||
const char *nick, const char *prefix)
|
||||
{
|
||||
GSList *tmp, *list;
|
||||
char *newprefix;
|
||||
|
||||
g_return_val_if_fail(nick != NULL, NULL);
|
||||
if (servers == NULL) return NULL;
|
||||
|
||||
list = NULL;
|
||||
if (find_server != NULL) {
|
||||
completion_msg_server(&list, find_server, nick, prefix);
|
||||
return convert_msglist(list);
|
||||
}
|
||||
|
||||
for (tmp = servers; tmp != NULL; tmp = tmp->next) {
|
||||
SERVER_REC *rec = tmp->data;
|
||||
|
||||
if (rec == win_server)
|
||||
newprefix = g_strdup(prefix);
|
||||
else {
|
||||
newprefix = prefix == NULL ?
|
||||
g_strdup_printf("-%s", rec->tag) :
|
||||
g_strdup_printf("%s -%s", prefix, rec->tag);
|
||||
}
|
||||
|
||||
completion_msg_server(&list, rec, nick, newprefix);
|
||||
g_free_not_null(newprefix);
|
||||
}
|
||||
|
||||
return convert_msglist(list);
|
||||
}
|
||||
|
||||
static void complete_from_nicklist(GList **outlist, GSList *list,
|
||||
const char *nick, const char *prefix)
|
||||
{
|
||||
GSList *tmp;
|
||||
char *str;
|
||||
int len, lowercase;
|
||||
|
||||
lowercase = settings_get_bool("completion_nicks_lowercase");
|
||||
|
||||
len = strlen(nick);
|
||||
for (tmp = list; tmp != NULL; tmp = tmp->next) {
|
||||
LAST_MSG_REC *rec = tmp->data;
|
||||
|
||||
if (g_strncasecmp(rec->nick, nick, len) == 0 &&
|
||||
glist_find_icase_string(*outlist, rec->nick) == NULL) {
|
||||
str = g_strconcat(rec->nick, prefix, NULL);
|
||||
if (lowercase) g_strdown(str);
|
||||
*outlist = g_list_append(*outlist, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static GList *completion_channel_nicks(CHANNEL_REC *channel, const char *nick,
|
||||
const char *prefix)
|
||||
{
|
||||
GSList *nicks, *tmp;
|
||||
GList *list;
|
||||
char *str;
|
||||
int lowercase, len;
|
||||
|
||||
g_return_val_if_fail(channel != NULL, NULL);
|
||||
g_return_val_if_fail(nick != NULL, NULL);
|
||||
if (*nick == '\0') return NULL;
|
||||
|
||||
lowercase = settings_get_bool("completion_nicks_lowercase");
|
||||
|
||||
if (prefix != NULL && *prefix == '\0')
|
||||
prefix = NULL;
|
||||
|
||||
/* put first the nicks who have recently said something [to you] */
|
||||
list = NULL;
|
||||
complete_from_nicklist(&list, channel->lastownmsgs, nick, prefix);
|
||||
complete_from_nicklist(&list, channel->lastmsgs, nick, prefix);
|
||||
|
||||
/* and add the rest of the nicks too */
|
||||
len = strlen(nick);
|
||||
nicks = nicklist_getnicks(channel);
|
||||
for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
|
||||
NICK_REC *rec = tmp->data;
|
||||
|
||||
if (g_strncasecmp(rec->nick, nick, len) == 0 &&
|
||||
glist_find_icase_string(list, rec->nick) == NULL &&
|
||||
g_strcasecmp(rec->nick, channel->server->nick) != 0) {
|
||||
str = g_strconcat(rec->nick, prefix, NULL);
|
||||
if (lowercase) g_strdown(str);
|
||||
list = g_list_append(list, str);
|
||||
}
|
||||
}
|
||||
g_slist_free(nicks);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static GList *completion_joinlist(GList *list1, GList *list2)
|
||||
{
|
||||
GList *old;
|
||||
|
||||
old = list2;
|
||||
while (list2 != NULL) {
|
||||
if (!glist_find_icase_string(list1, list2->data))
|
||||
list1 = g_list_append(list1, list2->data);
|
||||
else
|
||||
g_free(list2->data);
|
||||
|
||||
list2 = list2->next;
|
||||
}
|
||||
|
||||
g_list_free(old);
|
||||
return list1;
|
||||
}
|
||||
|
||||
GList *completion_get_channels(SERVER_REC *server, const char *word)
|
||||
{
|
||||
GList *list;
|
||||
GSList *tmp;
|
||||
int len;
|
||||
|
||||
g_return_val_if_fail(word != NULL, NULL);
|
||||
g_return_val_if_fail(*word != '\0', NULL);
|
||||
|
||||
len = strlen(word);
|
||||
list = NULL;
|
||||
|
||||
/* first get the joined channels */
|
||||
tmp = server == NULL ? NULL : server->channels;
|
||||
for (; tmp != NULL; tmp = tmp->next) {
|
||||
CHANNEL_REC *rec = tmp->data;
|
||||
|
||||
if (g_strncasecmp(rec->name, word, len) == 0)
|
||||
list = g_list_append(list, g_strdup(rec->name));
|
||||
}
|
||||
|
||||
/* get channels from setup */
|
||||
for (tmp = setupchannels; tmp != NULL; tmp = tmp->next) {
|
||||
CHANNEL_SETUP_REC *rec = tmp->data;
|
||||
|
||||
if (g_strncasecmp(rec->name, word, len) == 0)
|
||||
list = g_list_append(list, g_strdup(rec->name));
|
||||
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static void sig_complete_word(GList **list, WINDOW_REC *window,
|
||||
const char *word, const char *linestart)
|
||||
{
|
||||
SERVER_REC *server;
|
||||
CHANNEL_REC *channel;
|
||||
QUERY_REC *query;
|
||||
GList *tmplist;
|
||||
const char *cmdchars, *nickprefix;
|
||||
char *prefix;
|
||||
|
||||
g_return_if_fail(list != NULL);
|
||||
g_return_if_fail(window != NULL);
|
||||
g_return_if_fail(word != NULL);
|
||||
g_return_if_fail(linestart != NULL);
|
||||
|
||||
server = window->active_server;
|
||||
if (server == NULL && servers != NULL)
|
||||
server = servers->data;
|
||||
|
||||
if (server != NULL && server->ischannel(*word)) {
|
||||
/* probably completing a channel name */
|
||||
*list = completion_get_channels(window->active_server, word);
|
||||
return;
|
||||
}
|
||||
|
||||
server = window->active_server;
|
||||
if (server == NULL || !server->connected)
|
||||
return;
|
||||
|
||||
cmdchars = settings_get_str("cmdchars");
|
||||
if (*linestart == '\0' && *word == '\0') {
|
||||
/* pressed TAB at the start of line - add /MSG */
|
||||
prefix = g_strdup_printf("%cmsg", *cmdchars);
|
||||
*list = completion_msg(server, NULL, "", prefix);
|
||||
if (*list == NULL)
|
||||
*list = g_list_append(*list, g_strdup(prefix));
|
||||
g_free(prefix);
|
||||
|
||||
signal_stop();
|
||||
return;
|
||||
}
|
||||
|
||||
channel = CHANNEL(window->active);
|
||||
query = QUERY(window->active);
|
||||
if (channel == NULL && query != NULL) {
|
||||
/* completion in query */
|
||||
*list = g_list_append(*list, g_strdup(query->name));
|
||||
} else if (channel != NULL) {
|
||||
/* nick completion .. we could also be completing a nick
|
||||
after /MSG from nicks in channel */
|
||||
nickprefix = *linestart != '\0' ? NULL :
|
||||
settings_get_str("completion_char");
|
||||
|
||||
tmplist = completion_channel_nicks(channel, word, nickprefix);
|
||||
*list = completion_joinlist(*list, tmplist);
|
||||
}
|
||||
|
||||
if (*list != NULL) signal_stop();
|
||||
}
|
||||
|
||||
static SERVER_REC *line_get_server(const char *line)
|
||||
{
|
||||
SERVER_REC *server;
|
||||
char *tag, *ptr;
|
||||
|
||||
g_return_val_if_fail(line != NULL, NULL);
|
||||
if (*line != '-') return NULL;
|
||||
|
||||
/* -option found - should be server tag */
|
||||
tag = g_strdup(line+1);
|
||||
ptr = strchr(tag, ' ');
|
||||
if (ptr != NULL) *ptr = '\0';
|
||||
|
||||
server = server_find_tag(tag);
|
||||
|
||||
g_free(tag);
|
||||
return server;
|
||||
}
|
||||
|
||||
static void sig_complete_msg(GList **list, WINDOW_REC *window,
|
||||
const char *word, const char *line,
|
||||
int *want_space)
|
||||
{
|
||||
SERVER_REC *server, *msgserver;
|
||||
|
||||
g_return_if_fail(list != NULL);
|
||||
g_return_if_fail(word != NULL);
|
||||
g_return_if_fail(line != NULL);
|
||||
|
||||
server = window->active_server;
|
||||
if (server == NULL || !server->connected)
|
||||
return;
|
||||
|
||||
msgserver = line_get_server(line);
|
||||
*list = completion_msg(server, msgserver, word, NULL);
|
||||
if (*list != NULL) signal_stop();
|
||||
}
|
||||
|
||||
/* expand \n, \t and \\ */
|
||||
static char *expand_escapes(const char *line, SERVER_REC *server,
|
||||
WI_ITEM_REC *item)
|
||||
{
|
||||
char *ptr, *ret;
|
||||
|
||||
ret = ptr = g_malloc(strlen(line)+1);
|
||||
for (; *line != '\0'; line++) {
|
||||
if (*line != '\\') {
|
||||
*ptr++ = *line;
|
||||
continue;
|
||||
}
|
||||
|
||||
line++;
|
||||
if (*line == '\0') {
|
||||
*ptr++ = '\\';
|
||||
break;
|
||||
}
|
||||
|
||||
switch (*line) {
|
||||
case 'n':
|
||||
/* newline .. we need to send another "send text"
|
||||
event to handle it (or actually the text before
|
||||
the newline..) */
|
||||
*ptr = '\0';
|
||||
signal_emit("send text", 3, ret, server, item);
|
||||
ptr = ret;
|
||||
break;
|
||||
case 't':
|
||||
*ptr++ = '\t';
|
||||
break;
|
||||
case '\\':
|
||||
*ptr++ = '\\';
|
||||
break;
|
||||
default:
|
||||
*ptr++ = '\\';
|
||||
*ptr++ = *line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*ptr = '\0';
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void event_text(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
||||
{
|
||||
CHANNEL_REC *channel;
|
||||
GList *comp;
|
||||
char *line, *str, *ptr, comp_char;
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
if (item == NULL) return;
|
||||
|
||||
line = settings_get_bool("expand_escapes") ?
|
||||
expand_escapes(data, server, item) : g_strdup(data);
|
||||
comp_char = *settings_get_str("completion_char");
|
||||
|
||||
/* check for automatic nick completion */
|
||||
ptr = NULL;
|
||||
comp = NULL;
|
||||
channel = CHANNEL(item);
|
||||
|
||||
if (channel != NULL && comp_char != '\0' &&
|
||||
settings_get_bool("completion_auto")) {
|
||||
ptr = strchr(line, comp_char);
|
||||
if (ptr != NULL) {
|
||||
*ptr++ = '\0';
|
||||
if (nicklist_find(channel, line) == NULL) {
|
||||
comp = completion_channel_nicks(channel,
|
||||
line, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
str = g_strdup_printf(ptr == NULL ? "%s %s" : "%s %s%c%s", item->name,
|
||||
comp != NULL ? (char *) comp->data : line,
|
||||
comp_char, ptr);
|
||||
signal_emit("command msg", 3, str, server, item);
|
||||
|
||||
g_free(str);
|
||||
g_free(line);
|
||||
|
||||
if (comp != NULL) {
|
||||
g_list_foreach(comp, (GFunc) g_free, NULL);
|
||||
g_list_free(comp);
|
||||
}
|
||||
|
||||
signal_stop();
|
||||
}
|
||||
|
||||
static void sig_server_disconnected(SERVER_REC *server)
|
||||
{
|
||||
g_return_if_fail(server != NULL);
|
||||
|
||||
while (server->lastmsgs)
|
||||
SERVER_LAST_MSG_DESTROY(server, server->lastmsgs->data);
|
||||
}
|
||||
|
||||
static void sig_channel_destroyed(CHANNEL_REC *channel)
|
||||
{
|
||||
g_return_if_fail(channel != NULL);
|
||||
|
||||
while (channel->lastmsgs != NULL)
|
||||
last_msg_destroy(&channel->lastmsgs, channel->lastmsgs->data);
|
||||
while (channel->lastownmsgs != NULL)
|
||||
last_msg_destroy(&channel->lastownmsgs, channel->lastownmsgs->data);
|
||||
}
|
||||
|
||||
void chat_completion_init(void)
|
||||
{
|
||||
settings_add_str("completion", "completion_char", ":");
|
||||
settings_add_bool("completion", "completion_auto", FALSE);
|
||||
settings_add_int("completion", "completion_keep_publics", 180);
|
||||
settings_add_int("completion", "completion_keep_publics_count", 50);
|
||||
settings_add_int("completion", "completion_keep_ownpublics", 360);
|
||||
settings_add_int("completion", "completion_keep_privates", 10);
|
||||
settings_add_bool("completion", "expand_escapes", FALSE);
|
||||
settings_add_bool("completion", "completion_nicks_lowercase", FALSE);
|
||||
|
||||
complete_tag = g_timeout_add(1000, (GSourceFunc) nick_completion_timeout, NULL);
|
||||
|
||||
signal_add("complete word", (SIGNAL_FUNC) sig_complete_word);
|
||||
signal_add("complete command msg", (SIGNAL_FUNC) sig_complete_msg);
|
||||
signal_add("message public", (SIGNAL_FUNC) sig_message_public);
|
||||
signal_add("message private", (SIGNAL_FUNC) sig_message_private);
|
||||
signal_add("command msg", (SIGNAL_FUNC) cmd_msg);
|
||||
signal_add("nicklist remove", (SIGNAL_FUNC) sig_nick_removed);
|
||||
signal_add("nicklist changed", (SIGNAL_FUNC) sig_nick_changed);
|
||||
signal_add("send text", (SIGNAL_FUNC) event_text);
|
||||
signal_add("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
|
||||
signal_add("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
|
||||
}
|
||||
|
||||
void chat_completion_deinit(void)
|
||||
{
|
||||
g_source_remove(complete_tag);
|
||||
|
||||
signal_remove("complete word", (SIGNAL_FUNC) sig_complete_word);
|
||||
signal_remove("complete command msg", (SIGNAL_FUNC) sig_complete_msg);
|
||||
signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
|
||||
signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
|
||||
signal_remove("command msg", (SIGNAL_FUNC) cmd_msg);
|
||||
signal_remove("nicklist remove", (SIGNAL_FUNC) sig_nick_removed);
|
||||
signal_remove("nicklist changed", (SIGNAL_FUNC) sig_nick_changed);
|
||||
signal_remove("send text", (SIGNAL_FUNC) event_text);
|
||||
signal_remove("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
|
||||
signal_remove("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
|
||||
}
|
@ -43,6 +43,9 @@ static int last_want_space, last_line_pos;
|
||||
#define isseparator(c) \
|
||||
(isspace((int) (c)) || isseparator_notspace(c))
|
||||
|
||||
void chat_completion_init(void);
|
||||
void chat_completion_deinit(void);
|
||||
|
||||
/* Return whole word at specified position in string */
|
||||
char *get_word_at(const char *str, int pos, char **startpos)
|
||||
{
|
||||
@ -598,6 +601,8 @@ void completion_init(void)
|
||||
complist = NULL;
|
||||
last_line = NULL; last_line_pos = -1;
|
||||
|
||||
chat_completion_init();
|
||||
|
||||
signal_add_first("complete word", (SIGNAL_FUNC) sig_complete_word);
|
||||
signal_add("complete command set", (SIGNAL_FUNC) sig_complete_set);
|
||||
signal_add("complete command toggle", (SIGNAL_FUNC) sig_complete_toggle);
|
||||
@ -614,6 +619,8 @@ void completion_deinit(void)
|
||||
{
|
||||
free_completions();
|
||||
|
||||
chat_completion_deinit();
|
||||
|
||||
signal_remove("complete word", (SIGNAL_FUNC) sig_complete_word);
|
||||
signal_remove("complete command set", (SIGNAL_FUNC) sig_complete_set);
|
||||
signal_remove("complete command toggle", (SIGNAL_FUNC) sig_complete_toggle);
|
||||
|
@ -49,6 +49,9 @@ void fe_core_log_deinit(void);
|
||||
void fe_ignore_init(void);
|
||||
void fe_ignore_deinit(void);
|
||||
|
||||
void fe_ignore_messages_init(void);
|
||||
void fe_ignore_messages_deinit(void);
|
||||
|
||||
void fe_log_init(void);
|
||||
void fe_log_deinit(void);
|
||||
|
||||
@ -116,6 +119,8 @@ void fe_common_core_init(void)
|
||||
window_items_init();
|
||||
window_save_init();
|
||||
fe_core_commands_init();
|
||||
|
||||
fe_ignore_messages_init();
|
||||
}
|
||||
|
||||
void fe_common_core_deinit(void)
|
||||
@ -142,6 +147,8 @@ void fe_common_core_deinit(void)
|
||||
window_save_deinit();
|
||||
fe_core_commands_deinit();
|
||||
|
||||
fe_ignore_messages_init();
|
||||
|
||||
theme_unregister();
|
||||
themes_deinit();
|
||||
}
|
||||
|
130
src/fe-common/core/fe-ignore-messages.c
Normal file
130
src/fe-common/core/fe-ignore-messages.c
Normal file
@ -0,0 +1,130 @@
|
||||
/*
|
||||
fe-ignore-messages.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 "signals.h"
|
||||
#include "levels.h"
|
||||
#include "ignore.h"
|
||||
|
||||
static void sig_message_public(SERVER_REC *server, const char *msg,
|
||||
const char *nick, const char *address,
|
||||
const char *target)
|
||||
{
|
||||
if (ignore_check(server, nick, address, target, msg, MSGLEVEL_PUBLIC))
|
||||
signal_stop();
|
||||
}
|
||||
|
||||
static void sig_message_private(SERVER_REC *server, const char *msg,
|
||||
const char *nick, const char *address)
|
||||
{
|
||||
if (ignore_check(server, nick, address, NULL, msg, MSGLEVEL_MSGS))
|
||||
signal_stop();
|
||||
}
|
||||
|
||||
static void sig_message_join(SERVER_REC *server, const char *channel,
|
||||
const char *nick, const char *address)
|
||||
{
|
||||
if (ignore_check(server, nick, address, channel, NULL, MSGLEVEL_JOINS))
|
||||
signal_stop();
|
||||
}
|
||||
|
||||
static void sig_message_part(SERVER_REC *server, const char *channel,
|
||||
const char *nick, const char *address,
|
||||
const char *reason)
|
||||
{
|
||||
if (ignore_check(server, nick, address, channel, NULL, MSGLEVEL_PARTS))
|
||||
signal_stop();
|
||||
}
|
||||
|
||||
static void sig_message_quit(SERVER_REC *server, const char *nick,
|
||||
const char *address, const char *reason)
|
||||
{
|
||||
if (ignore_check(server, nick, address, NULL, reason, MSGLEVEL_QUITS))
|
||||
signal_stop();
|
||||
}
|
||||
|
||||
static void sig_message_kick(SERVER_REC *server, const char *channel,
|
||||
const char *nick, const char *kicker,
|
||||
const char *address, const char *reason)
|
||||
{
|
||||
if (ignore_check(server, kicker, address,
|
||||
channel, reason, MSGLEVEL_KICKS))
|
||||
signal_stop();
|
||||
}
|
||||
|
||||
static void sig_message_nick(SERVER_REC *server, const char *newnick,
|
||||
const char *oldnick, const char *address)
|
||||
{
|
||||
if (ignore_check(server, oldnick, address, NULL, NULL, MSGLEVEL_NICKS))
|
||||
signal_stop();
|
||||
}
|
||||
|
||||
static void sig_message_own_nick(SERVER_REC *server, const char *newnick,
|
||||
const char *oldnick, const char *address)
|
||||
{
|
||||
if (ignore_check(server, oldnick, address, NULL, NULL, MSGLEVEL_NICKS))
|
||||
signal_stop();
|
||||
}
|
||||
|
||||
static void sig_message_invite(SERVER_REC *server, const char *channel,
|
||||
const char *nick, const char *address)
|
||||
{
|
||||
if (*channel == '\0' ||
|
||||
ignore_check(server, nick, address,
|
||||
channel, NULL, MSGLEVEL_INVITES))
|
||||
signal_stop();
|
||||
}
|
||||
|
||||
static void sig_message_topic(SERVER_REC *server, const char *channel,
|
||||
const char *topic,
|
||||
const char *nick, const char *address)
|
||||
{
|
||||
if (ignore_check(server, nick, address,
|
||||
channel, topic, MSGLEVEL_TOPICS))
|
||||
signal_stop();
|
||||
}
|
||||
|
||||
void fe_ignore_messages_init(void)
|
||||
{
|
||||
signal_add_first("message public", (SIGNAL_FUNC) sig_message_public);
|
||||
signal_add_first("message private", (SIGNAL_FUNC) sig_message_private);
|
||||
signal_add_first("message join", (SIGNAL_FUNC) sig_message_join);
|
||||
signal_add_first("message part", (SIGNAL_FUNC) sig_message_part);
|
||||
signal_add_first("message quit", (SIGNAL_FUNC) sig_message_quit);
|
||||
signal_add_first("message kick", (SIGNAL_FUNC) sig_message_kick);
|
||||
signal_add_first("message nick", (SIGNAL_FUNC) sig_message_nick);
|
||||
signal_add_first("message own_nick", (SIGNAL_FUNC) sig_message_own_nick);
|
||||
signal_add_first("message invite", (SIGNAL_FUNC) sig_message_invite);
|
||||
signal_add_first("message topic", (SIGNAL_FUNC) sig_message_topic);
|
||||
}
|
||||
|
||||
void fe_ignore_messages_deinit(void)
|
||||
{
|
||||
signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
|
||||
signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
|
||||
signal_remove("message join", (SIGNAL_FUNC) sig_message_join);
|
||||
signal_remove("message part", (SIGNAL_FUNC) sig_message_part);
|
||||
signal_remove("message quit", (SIGNAL_FUNC) sig_message_quit);
|
||||
signal_remove("message kick", (SIGNAL_FUNC) sig_message_kick);
|
||||
signal_remove("message nick", (SIGNAL_FUNC) sig_message_nick);
|
||||
signal_remove("message own_nick", (SIGNAL_FUNC) sig_message_own_nick);
|
||||
signal_remove("message invite", (SIGNAL_FUNC) sig_message_invite);
|
||||
signal_remove("message topic", (SIGNAL_FUNC) sig_message_topic);
|
||||
}
|
@ -55,9 +55,6 @@ static void sig_message_public(SERVER_REC *server, const char *msg,
|
||||
int for_me, print_channel, level;
|
||||
char *color;
|
||||
|
||||
if (ignore_check(server, nick, address, target, msg, MSGLEVEL_PUBLIC))
|
||||
return;
|
||||
|
||||
chanrec = channel_find(server, target);
|
||||
for_me = nick_match_msg(server, msg, server->nick);
|
||||
color = for_me ? NULL :
|
||||
@ -107,9 +104,6 @@ static void sig_message_private(SERVER_REC *server, const char *msg,
|
||||
{
|
||||
QUERY_REC *query;
|
||||
|
||||
if (ignore_check(server, nick, address, NULL, msg, MSGLEVEL_MSGS))
|
||||
return;
|
||||
|
||||
query = query_find(server, nick);
|
||||
printformat(server, nick, MSGLEVEL_MSGS,
|
||||
query == NULL ? IRCTXT_MSG_PRIVATE :
|
||||
@ -214,9 +208,6 @@ static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
||||
static void sig_message_join(SERVER_REC *server, const char *channel,
|
||||
const char *nick, const char *address)
|
||||
{
|
||||
if (ignore_check(server, nick, address, channel, NULL, MSGLEVEL_JOINS))
|
||||
return;
|
||||
|
||||
printformat(server, channel, MSGLEVEL_JOINS,
|
||||
IRCTXT_JOIN, nick, address, channel);
|
||||
}
|
||||
@ -225,9 +216,6 @@ static void sig_message_part(SERVER_REC *server, const char *channel,
|
||||
const char *nick, const char *address,
|
||||
const char *reason)
|
||||
{
|
||||
if (ignore_check(server, nick, address, channel, NULL, MSGLEVEL_PARTS))
|
||||
return;
|
||||
|
||||
printformat(server, channel, MSGLEVEL_PARTS,
|
||||
IRCTXT_PART, nick, address, channel, reason);
|
||||
}
|
||||
@ -241,9 +229,6 @@ static void sig_message_quit(SERVER_REC *server, const char *nick,
|
||||
char *print_channel;
|
||||
int once, count;
|
||||
|
||||
if (ignore_check(server, nick, address, NULL, reason, MSGLEVEL_QUITS))
|
||||
return;
|
||||
|
||||
print_channel = NULL;
|
||||
once = settings_get_bool("show_quit_once");
|
||||
|
||||
@ -289,10 +274,6 @@ static void sig_message_kick(SERVER_REC *server, const char *channel,
|
||||
const char *nick, const char *kicker,
|
||||
const char *address, const char *reason)
|
||||
{
|
||||
if (ignore_check(server, kicker, address,
|
||||
channel, reason, MSGLEVEL_KICKS))
|
||||
return;
|
||||
|
||||
printformat(server, channel, MSGLEVEL_KICKS,
|
||||
IRCTXT_KICK, nick, channel, kicker, reason);
|
||||
}
|
||||
@ -318,9 +299,6 @@ static void print_nick_change(SERVER_REC *server, const char *newnick,
|
||||
GSList *tmp, *windows;
|
||||
int msgprint;
|
||||
|
||||
if (ignore_check(server, oldnick, address, NULL, NULL, MSGLEVEL_NICKS))
|
||||
return;
|
||||
|
||||
msgprint = FALSE;
|
||||
|
||||
/* Print to each channel/query where the nick is.
|
||||
@ -380,11 +358,6 @@ static void sig_message_invite(SERVER_REC *server, const char *channel,
|
||||
{
|
||||
char *str;
|
||||
|
||||
if (*channel == '\0' ||
|
||||
ignore_check(server, nick, address,
|
||||
channel, NULL, MSGLEVEL_INVITES))
|
||||
return;
|
||||
|
||||
str = show_lowascii(channel);
|
||||
printformat(server, NULL, MSGLEVEL_INVITES,
|
||||
IRCTXT_INVITE, nick, str);
|
||||
@ -395,10 +368,6 @@ static void sig_message_topic(SERVER_REC *server, const char *channel,
|
||||
const char *topic,
|
||||
const char *nick, const char *address)
|
||||
{
|
||||
if (ignore_check(server, nick, address,
|
||||
channel, topic, MSGLEVEL_TOPICS))
|
||||
return;
|
||||
|
||||
printformat(server, channel, MSGLEVEL_TOPICS,
|
||||
*topic != '\0' ? IRCTXT_NEW_TOPIC : IRCTXT_TOPIC_UNSET,
|
||||
nick, channel, topic);
|
||||
|
@ -22,7 +22,6 @@ libfe_common_irc_a_SOURCES = \
|
||||
fe-netjoin.c \
|
||||
fe-netsplit.c \
|
||||
fe-common-irc.c \
|
||||
irc-completion.c \
|
||||
irc-modules.c \
|
||||
module-formats.c
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "servers-setup.h"
|
||||
|
||||
#include "themes.h"
|
||||
#include "completion.h"
|
||||
|
||||
void fe_irc_modules_init(void);
|
||||
void fe_irc_modules_deinit(void);
|
||||
@ -55,9 +54,6 @@ void fe_events_deinit(void);
|
||||
void fe_events_numeric_init(void);
|
||||
void fe_events_numeric_deinit(void);
|
||||
|
||||
void irc_completion_init(void);
|
||||
void irc_completion_deinit(void);
|
||||
|
||||
void fe_netsplit_init(void);
|
||||
void fe_netsplit_deinit(void);
|
||||
|
||||
@ -104,7 +100,6 @@ void fe_common_irc_init(void)
|
||||
fe_events_numeric_init();
|
||||
fe_netsplit_init();
|
||||
fe_netjoin_init();
|
||||
irc_completion_init();
|
||||
|
||||
fe_irc_modules_init();
|
||||
}
|
||||
@ -122,7 +117,6 @@ void fe_common_irc_deinit(void)
|
||||
fe_events_numeric_deinit();
|
||||
fe_netsplit_deinit();
|
||||
fe_netjoin_deinit();
|
||||
irc_completion_deinit();
|
||||
|
||||
theme_unregister();
|
||||
}
|
||||
|
@ -1,755 +0,0 @@
|
||||
/*
|
||||
completion.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 "misc.h"
|
||||
#include "lib-config/iconfig.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include "irc.h"
|
||||
#include "servers.h"
|
||||
#include "irc-channels.h"
|
||||
#include "irc-queries.h"
|
||||
#include "channels-setup.h"
|
||||
#include "irc-nicklist.h"
|
||||
|
||||
#include "completion.h"
|
||||
#include "window-items.h"
|
||||
|
||||
static int complete_tag;
|
||||
|
||||
typedef struct {
|
||||
time_t time;
|
||||
char *nick;
|
||||
} NICK_COMPLETION_REC;
|
||||
|
||||
GList *completion_get_channels(IRC_SERVER_REC *server, const char *word)
|
||||
{
|
||||
GList *list;
|
||||
GSList *tmp;
|
||||
int len;
|
||||
|
||||
g_return_val_if_fail(word != NULL, NULL);
|
||||
g_return_val_if_fail(*word != '\0', NULL);
|
||||
|
||||
len = strlen(word);
|
||||
list = NULL;
|
||||
|
||||
/* first get the joined channels */
|
||||
tmp = server == NULL ? NULL : server->channels;
|
||||
for (; tmp != NULL; tmp = tmp->next) {
|
||||
CHANNEL_REC *rec = tmp->data;
|
||||
|
||||
if (g_strncasecmp(rec->name, word, len) == 0)
|
||||
list = g_list_append(list, g_strdup(rec->name));
|
||||
}
|
||||
|
||||
/* get channels from setup */
|
||||
for (tmp = setupchannels; tmp != NULL; tmp = tmp->next) {
|
||||
CHANNEL_SETUP_REC *rec = tmp->data;
|
||||
|
||||
if (g_strncasecmp(rec->name, word, len) == 0)
|
||||
list = g_list_append(list, g_strdup(rec->name));
|
||||
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static void nick_completion_destroy(GSList **list, NICK_COMPLETION_REC *rec)
|
||||
{
|
||||
*list = g_slist_remove(*list, rec);
|
||||
|
||||
g_free(rec->nick);
|
||||
g_free(rec);
|
||||
}
|
||||
|
||||
static void nick_completion_remove_old(GSList **list, int timeout, time_t now)
|
||||
{
|
||||
GSList *tmp, *next;
|
||||
|
||||
for (tmp = *list; tmp != NULL; tmp = next) {
|
||||
NICK_COMPLETION_REC *rec = tmp->data;
|
||||
|
||||
next = tmp->next;
|
||||
if (now-rec->time > timeout)
|
||||
nick_completion_destroy(list, rec);
|
||||
}
|
||||
}
|
||||
|
||||
static void last_msg_add(MODULE_SERVER_REC *mserver, const char *nick)
|
||||
{
|
||||
LAST_MSG_REC *rec;
|
||||
|
||||
rec = g_new(LAST_MSG_REC, 1);
|
||||
rec->time = time(NULL);
|
||||
rec->nick = g_strdup(nick);
|
||||
|
||||
mserver->lastmsgs = g_slist_append(mserver->lastmsgs, rec);
|
||||
}
|
||||
|
||||
static void last_msg_free(MODULE_SERVER_REC *mserver, LAST_MSG_REC *rec)
|
||||
{
|
||||
mserver->lastmsgs = g_slist_remove(mserver->lastmsgs, rec);
|
||||
|
||||
g_free(rec->nick);
|
||||
g_free(rec);
|
||||
}
|
||||
|
||||
static LAST_MSG_REC *last_msg_find(MODULE_SERVER_REC *mserver, const char *nick)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
for (tmp = mserver->lastmsgs; tmp != NULL; tmp = tmp->next) {
|
||||
LAST_MSG_REC *rec = tmp->data;
|
||||
|
||||
if (g_strcasecmp(rec->nick, nick) == 0)
|
||||
return rec;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int last_msg_cmp(LAST_MSG_REC *m1, LAST_MSG_REC *m2)
|
||||
{
|
||||
return m1->time < m2->time ? 1 : -1;
|
||||
}
|
||||
|
||||
static int nick_completion_timeout(void)
|
||||
{
|
||||
MODULE_SERVER_REC *mserver;
|
||||
MODULE_CHANNEL_REC *mchannel;
|
||||
GSList *tmp;
|
||||
time_t now;
|
||||
int len;
|
||||
|
||||
now = time(NULL);
|
||||
for (tmp = servers; tmp != NULL; tmp = tmp->next) {
|
||||
IRC_SERVER_REC *rec = tmp->data;
|
||||
|
||||
if (!IS_IRC_SERVER(rec))
|
||||
continue;
|
||||
|
||||
mserver = MODULE_DATA(rec);
|
||||
len = g_slist_length(mserver->lastmsgs);
|
||||
if (len > 0 && len >= settings_get_int("completion_keep_privates")) {
|
||||
/* remove the oldest msg nick. */
|
||||
last_msg_free(mserver, mserver->lastmsgs->data);
|
||||
}
|
||||
}
|
||||
|
||||
for (tmp = channels; tmp != NULL; tmp = tmp->next) {
|
||||
CHANNEL_REC *rec = tmp->data;
|
||||
|
||||
mchannel = MODULE_DATA(rec);
|
||||
nick_completion_remove_old(&mchannel->lastownmsgs, settings_get_int("completion_keep_ownpublics"), now);
|
||||
nick_completion_remove_old(&mchannel->lastmsgs, settings_get_int("completion_keep_publics"), now);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static NICK_COMPLETION_REC *nick_completion_find(GSList *list, const char *nick)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
for (tmp = list; tmp != NULL; tmp = tmp->next) {
|
||||
NICK_COMPLETION_REC *rec = tmp->data;
|
||||
|
||||
if (g_strcasecmp(rec->nick, nick) == 0)
|
||||
return rec;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static NICK_COMPLETION_REC *nick_completion_create(GSList **list, time_t time, const char *nick)
|
||||
{
|
||||
NICK_COMPLETION_REC *rec;
|
||||
|
||||
rec = nick_completion_find(*list, nick);
|
||||
if (rec != NULL) {
|
||||
/* remove the old one */
|
||||
nick_completion_destroy(list, rec);
|
||||
}
|
||||
|
||||
rec = g_new(NICK_COMPLETION_REC, 1);
|
||||
*list = g_slist_prepend(*list, rec);
|
||||
|
||||
rec->time = time;
|
||||
rec->nick = g_strdup(nick);
|
||||
return rec;
|
||||
}
|
||||
|
||||
static void add_private_msg(IRC_SERVER_REC *server, const char *nick)
|
||||
{
|
||||
MODULE_SERVER_REC *mserver;
|
||||
LAST_MSG_REC *msg;
|
||||
|
||||
mserver = MODULE_DATA(server);
|
||||
msg = last_msg_find(mserver, nick);
|
||||
if (msg != NULL)
|
||||
msg->time = time(NULL);
|
||||
else
|
||||
last_msg_add(mserver, nick);
|
||||
}
|
||||
|
||||
static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *nick)
|
||||
{
|
||||
char *params, *target, *msg;
|
||||
GSList **list;
|
||||
|
||||
g_return_if_fail(server != NULL);
|
||||
if (nick == NULL) return; /* from server */
|
||||
|
||||
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
|
||||
|
||||
if (ischannel(*target)) {
|
||||
/* channel message */
|
||||
MODULE_CHANNEL_REC *mchannel;
|
||||
IRC_CHANNEL_REC *channel;
|
||||
|
||||
channel = irc_channel_find(server, target);
|
||||
if (channel == NULL) {
|
||||
g_free(params);
|
||||
return;
|
||||
}
|
||||
|
||||
mchannel = MODULE_DATA(channel);
|
||||
list = nick_match_msg(SERVER(server), msg, server->nick) ?
|
||||
&mchannel->lastownmsgs :
|
||||
&mchannel->lastmsgs;
|
||||
nick_completion_create(list, time(NULL), nick);
|
||||
} else {
|
||||
/* private message */
|
||||
add_private_msg(server, nick);
|
||||
}
|
||||
|
||||
g_free(params);
|
||||
}
|
||||
|
||||
static void cmd_msg(const char *data, IRC_SERVER_REC *server)
|
||||
{
|
||||
GHashTable *optlist;
|
||||
char *target, *msg;
|
||||
void *free_arg;
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
|
||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS |
|
||||
PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
|
||||
"msg", &optlist, &target, &msg))
|
||||
return;
|
||||
server = IRC_SERVER(cmd_options_get_server("msg", optlist, SERVER(server)));
|
||||
|
||||
if (*target != '\0' && *msg != '\0') {
|
||||
if (!ischannel(*target) && *target != '=' && server != NULL)
|
||||
add_private_msg(server, target);
|
||||
}
|
||||
|
||||
cmd_params_free(free_arg);
|
||||
}
|
||||
|
||||
static void sig_nick_removed(CHANNEL_REC *channel, NICK_REC *nick)
|
||||
{
|
||||
NICK_COMPLETION_REC *rec;
|
||||
MODULE_CHANNEL_REC *mchannel;
|
||||
|
||||
mchannel = MODULE_DATA(channel);
|
||||
|
||||
rec = nick_completion_find(mchannel->lastownmsgs, nick->nick);
|
||||
if (rec != NULL) nick_completion_destroy(&mchannel->lastownmsgs, rec);
|
||||
|
||||
rec = nick_completion_find(mchannel->lastmsgs, nick->nick);
|
||||
if (rec != NULL) nick_completion_destroy(&mchannel->lastmsgs, rec);
|
||||
}
|
||||
|
||||
static void sig_nick_changed(CHANNEL_REC *channel, NICK_REC *nick, const char *oldnick)
|
||||
{
|
||||
NICK_COMPLETION_REC *rec;
|
||||
MODULE_CHANNEL_REC *mchannel;
|
||||
|
||||
mchannel = MODULE_DATA(channel);
|
||||
|
||||
rec = nick_completion_find(mchannel->lastownmsgs, oldnick);
|
||||
if (rec != NULL) {
|
||||
g_free(rec->nick);
|
||||
rec->nick = g_strdup(nick->nick);
|
||||
}
|
||||
|
||||
rec = nick_completion_find(mchannel->lastmsgs, oldnick);
|
||||
if (rec != NULL) {
|
||||
g_free(rec->nick);
|
||||
rec->nick = g_strdup(nick->nick);
|
||||
}
|
||||
}
|
||||
|
||||
/* Complete /MSG from specified server */
|
||||
static void completion_msg_server(GSList **list, IRC_SERVER_REC *server,
|
||||
const char *nick, const char *prefix)
|
||||
{
|
||||
MODULE_SERVER_REC *mserver;
|
||||
LAST_MSG_REC *msg;
|
||||
GSList *tmp;
|
||||
int len;
|
||||
|
||||
g_return_if_fail(nick != NULL);
|
||||
|
||||
mserver = MODULE_DATA(server);
|
||||
len = strlen(nick);
|
||||
for (tmp = mserver->lastmsgs; tmp != NULL; tmp = tmp->next) {
|
||||
LAST_MSG_REC *rec = tmp->data;
|
||||
|
||||
if (len != 0 && g_strncasecmp(rec->nick, nick, len) != 0)
|
||||
continue;
|
||||
|
||||
msg = g_new(LAST_MSG_REC, 1);
|
||||
msg->time = rec->time;
|
||||
msg->nick = prefix == NULL || *prefix == '\0' ?
|
||||
g_strdup(rec->nick) :
|
||||
g_strconcat(prefix, " ", rec->nick, NULL);
|
||||
*list = g_slist_insert_sorted(*list, msg,
|
||||
(GCompareFunc) last_msg_cmp);
|
||||
}
|
||||
}
|
||||
|
||||
static GList *convert_msglist(GSList *msglist)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
list = NULL;
|
||||
while (msglist != NULL) {
|
||||
LAST_MSG_REC *rec = msglist->data;
|
||||
|
||||
list = g_list_append(list, rec->nick);
|
||||
msglist = g_slist_remove(msglist, rec);
|
||||
g_free(rec);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/* Complete /MSG - if `find_server' is NULL, complete nicks from all servers */
|
||||
static GList *completion_msg(IRC_SERVER_REC *win_server,
|
||||
IRC_SERVER_REC *find_server,
|
||||
const char *nick, const char *prefix)
|
||||
{
|
||||
GSList *tmp, *list;
|
||||
char *newprefix;
|
||||
|
||||
g_return_val_if_fail(nick != NULL, NULL);
|
||||
if (servers == NULL) return NULL;
|
||||
|
||||
list = NULL;
|
||||
if (find_server != NULL) {
|
||||
completion_msg_server(&list, find_server, nick, prefix);
|
||||
return convert_msglist(list);
|
||||
}
|
||||
|
||||
for (tmp = servers; tmp != NULL; tmp = tmp->next) {
|
||||
IRC_SERVER_REC *rec = tmp->data;
|
||||
|
||||
if (!IS_IRC_SERVER(rec))
|
||||
continue;
|
||||
|
||||
if (rec == win_server)
|
||||
newprefix = g_strdup(prefix);
|
||||
else {
|
||||
newprefix = prefix == NULL ?
|
||||
g_strdup_printf("-%s", rec->tag) :
|
||||
g_strdup_printf("%s -%s", prefix, rec->tag);
|
||||
}
|
||||
|
||||
completion_msg_server(&list, rec, nick, newprefix);
|
||||
g_free_not_null(newprefix);
|
||||
}
|
||||
|
||||
return convert_msglist(list);
|
||||
}
|
||||
|
||||
static void complete_from_nicklist(GList **outlist, GSList *list,
|
||||
const char *nick, const char *prefix,
|
||||
int lowercase)
|
||||
{
|
||||
GSList *tmp;
|
||||
char *str;
|
||||
int len;
|
||||
|
||||
len = strlen(nick);
|
||||
for (tmp = list; tmp != NULL; tmp = tmp->next) {
|
||||
NICK_COMPLETION_REC *rec = tmp->data;
|
||||
|
||||
if (g_strncasecmp(rec->nick, nick, len) == 0 &&
|
||||
glist_find_icase_string(*outlist, rec->nick) == NULL) {
|
||||
if (prefix == NULL || *prefix == '\0')
|
||||
str = g_strdup(rec->nick);
|
||||
else
|
||||
str = g_strconcat(rec->nick, prefix, NULL);
|
||||
if (lowercase) g_strdown(str);
|
||||
*outlist = g_list_append(*outlist, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static GList *completion_channel_nicks(IRC_CHANNEL_REC *channel, const char *nick, const char *prefix)
|
||||
{
|
||||
MODULE_CHANNEL_REC *mchannel;
|
||||
GSList *nicks, *tmp;
|
||||
GList *list;
|
||||
int lowercase, len;
|
||||
|
||||
g_return_val_if_fail(channel != NULL, NULL);
|
||||
g_return_val_if_fail(nick != NULL, NULL);
|
||||
if (*nick == '\0') return NULL;
|
||||
|
||||
lowercase = settings_get_bool("completion_nicks_lowercase");
|
||||
|
||||
/* put first the nicks who have recently said something [to you] */
|
||||
list = NULL;
|
||||
mchannel = MODULE_DATA(channel);
|
||||
complete_from_nicklist(&list, mchannel->lastownmsgs, nick, prefix, lowercase);
|
||||
complete_from_nicklist(&list, mchannel->lastmsgs, nick, prefix, lowercase);
|
||||
|
||||
/* and add the rest of the nicks too */
|
||||
len = strlen(nick);
|
||||
nicks = nicklist_getnicks(CHANNEL(channel));
|
||||
for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
|
||||
NICK_REC *rec = tmp->data;
|
||||
|
||||
if (g_strncasecmp(rec->nick, nick, len) == 0 &&
|
||||
glist_find_icase_string(list, rec->nick) == NULL &&
|
||||
g_strcasecmp(rec->nick, channel->server->nick) != 0) {
|
||||
char *str;
|
||||
if (prefix == NULL || *prefix == '\0')
|
||||
str = g_strdup(rec->nick);
|
||||
else
|
||||
str = g_strconcat(rec->nick, prefix, NULL);
|
||||
if (lowercase) g_strdown(str);
|
||||
list = g_list_append(list, str);
|
||||
}
|
||||
}
|
||||
g_slist_free(nicks);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static GList *completion_joinlist(GList *list1, GList *list2)
|
||||
{
|
||||
GList *old;
|
||||
|
||||
old = list2;
|
||||
while (list2 != NULL) {
|
||||
if (!glist_find_icase_string(list1, list2->data))
|
||||
list1 = g_list_append(list1, list2->data);
|
||||
else
|
||||
g_free(list2->data);
|
||||
|
||||
list2 = list2->next;
|
||||
}
|
||||
|
||||
g_list_free(old);
|
||||
return list1;
|
||||
}
|
||||
|
||||
static void sig_complete_word(GList **list, WINDOW_REC *window,
|
||||
const char *word, const char *linestart)
|
||||
{
|
||||
IRC_SERVER_REC *server;
|
||||
IRC_CHANNEL_REC *channel;
|
||||
GList *tmplist;
|
||||
const char *cmdchars, *nickprefix;
|
||||
char *prefix;
|
||||
|
||||
g_return_if_fail(list != NULL);
|
||||
g_return_if_fail(window != NULL);
|
||||
g_return_if_fail(word != NULL);
|
||||
g_return_if_fail(linestart != NULL);
|
||||
|
||||
if (ischannel(*word)) {
|
||||
/* probably completing a channel name */
|
||||
*list = completion_get_channels((IRC_SERVER_REC *) window->active_server, word);
|
||||
return;
|
||||
}
|
||||
|
||||
server = IRC_SERVER(window->active_server);
|
||||
if (server == NULL || !server->connected)
|
||||
return;
|
||||
|
||||
cmdchars = settings_get_str("cmdchars");
|
||||
if (*linestart == '\0' && *word == '\0') {
|
||||
/* pressed TAB at the start of line - add /MSG */
|
||||
prefix = g_strdup_printf("%cmsg", *cmdchars);
|
||||
*list = completion_msg(server, NULL, "", prefix);
|
||||
if (*list == NULL) *list = g_list_append(*list, g_strdup(prefix));
|
||||
g_free(prefix);
|
||||
|
||||
signal_stop();
|
||||
return;
|
||||
}
|
||||
|
||||
/* nick completion .. we could also be completing a nick after /MSG
|
||||
from nicks in channel */
|
||||
channel = IRC_CHANNEL(window->active);
|
||||
if (channel == NULL)
|
||||
return;
|
||||
|
||||
nickprefix = *linestart != '\0' ? NULL :
|
||||
settings_get_str("completion_char");
|
||||
|
||||
tmplist = completion_channel_nicks(channel, word, nickprefix);
|
||||
*list = completion_joinlist(*list, tmplist);
|
||||
|
||||
if (*list != NULL) signal_stop();
|
||||
}
|
||||
|
||||
static IRC_SERVER_REC *line_get_server(const char *line)
|
||||
{
|
||||
IRC_SERVER_REC *server;
|
||||
char *tag, *ptr;
|
||||
|
||||
g_return_val_if_fail(line != NULL, NULL);
|
||||
if (*line != '-') return NULL;
|
||||
|
||||
/* -option found - should be server tag */
|
||||
tag = g_strdup(line+1);
|
||||
ptr = strchr(tag, ' ');
|
||||
if (ptr != NULL) *ptr = '\0';
|
||||
|
||||
server = (IRC_SERVER_REC *) server_find_tag(tag);
|
||||
|
||||
g_free(tag);
|
||||
return server;
|
||||
}
|
||||
|
||||
static void sig_complete_msg(GList **list, WINDOW_REC *window,
|
||||
const char *word, const char *line, int *want_space)
|
||||
{
|
||||
IRC_SERVER_REC *server, *msgserver;
|
||||
|
||||
g_return_if_fail(list != NULL);
|
||||
g_return_if_fail(word != NULL);
|
||||
g_return_if_fail(line != NULL);
|
||||
|
||||
server = IRC_SERVER(window->active_server);
|
||||
if (server == NULL || !server->connected)
|
||||
return;
|
||||
|
||||
msgserver = line_get_server(line);
|
||||
*list = completion_msg(server, msgserver, word, NULL);
|
||||
if (*list != NULL) signal_stop();
|
||||
}
|
||||
|
||||
/* expand \n, \t and \\ - FIXME: this doesn't work right */
|
||||
static char *expand_escapes(const char *line, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||
{
|
||||
char *ptr, *ret;
|
||||
|
||||
ret = ptr = g_malloc(strlen(line)+1);
|
||||
while (*line != '\0') {
|
||||
if (*line != '\\')
|
||||
*ptr++ = *line;
|
||||
else {
|
||||
line++;
|
||||
if (*line == '\0') {
|
||||
*ptr++ = '\\';
|
||||
break;
|
||||
}
|
||||
|
||||
switch (*line) {
|
||||
case 'n':
|
||||
/* newline .. we need to send another "send text" event to handle it (or actually the text before the newline..) */
|
||||
*ptr = '\0';
|
||||
signal_emit("send text", 3, ret, server, item);
|
||||
ptr = ret;
|
||||
break;
|
||||
case 't':
|
||||
*ptr++ = '\t';
|
||||
break;
|
||||
case '\\':
|
||||
*ptr++ = '\\';
|
||||
break;
|
||||
default:
|
||||
*ptr++ = '\\';
|
||||
*ptr++ = *line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
line++;
|
||||
}
|
||||
|
||||
*ptr = '\0';
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void event_text(gchar *line, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||
{
|
||||
IRC_CHANNEL_REC *channel;
|
||||
GList *comp;
|
||||
gchar *str, *ptr;
|
||||
|
||||
g_return_if_fail(line != NULL);
|
||||
|
||||
if (!IS_IRC_ITEM(item))
|
||||
return;
|
||||
|
||||
/* FIXME: this really should go to fe-common/core. */
|
||||
line = settings_get_bool("expand_escapes") ?
|
||||
expand_escapes(line, server, item) : g_strdup(line);
|
||||
|
||||
/* check for nick completion */
|
||||
if (!settings_get_bool("completion_auto") ||
|
||||
*settings_get_str("completion_char") == '\0')
|
||||
{
|
||||
ptr = NULL;
|
||||
comp = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = strchr(line, *settings_get_str("completion_char"));
|
||||
if (ptr != NULL) *ptr++ = '\0';
|
||||
|
||||
channel = IRC_CHANNEL(item);
|
||||
|
||||
comp = ptr == NULL || channel == NULL ||
|
||||
nicklist_find(CHANNEL(channel), line) != NULL ? NULL :
|
||||
completion_channel_nicks(channel, line, NULL);
|
||||
}
|
||||
|
||||
/* message to channel */
|
||||
if (ptr == NULL)
|
||||
str = g_strdup_printf("%s %s", item->name, line);
|
||||
else
|
||||
{
|
||||
str = g_strdup_printf("%s %s%s%s", item->name,
|
||||
comp != NULL ? (gchar *) comp->data : line,
|
||||
settings_get_str("completion_char"), ptr);
|
||||
}
|
||||
signal_emit("command msg", 3, str, server, item);
|
||||
|
||||
g_free(str);
|
||||
g_free(line);
|
||||
|
||||
if (comp != NULL)
|
||||
{
|
||||
g_list_foreach(comp, (GFunc) g_free, NULL);
|
||||
g_list_free(comp);
|
||||
}
|
||||
|
||||
signal_stop();
|
||||
}
|
||||
|
||||
static void completion_init_server(IRC_SERVER_REC *server)
|
||||
{
|
||||
MODULE_SERVER_REC *rec;
|
||||
|
||||
g_return_if_fail(server != NULL);
|
||||
|
||||
if (!IS_IRC_SERVER(server))
|
||||
return;
|
||||
|
||||
rec = g_new0(MODULE_SERVER_REC, 1);
|
||||
MODULE_DATA_SET(server, rec);
|
||||
}
|
||||
|
||||
static void completion_deinit_server(IRC_SERVER_REC *server)
|
||||
{
|
||||
MODULE_SERVER_REC *mserver;
|
||||
|
||||
g_return_if_fail(server != NULL);
|
||||
|
||||
if (!IS_IRC_SERVER(server))
|
||||
return;
|
||||
|
||||
mserver = MODULE_DATA(server);
|
||||
while (mserver->lastmsgs)
|
||||
last_msg_free(mserver, mserver->lastmsgs->data);
|
||||
g_free(mserver);
|
||||
}
|
||||
|
||||
static void completion_init_channel(CHANNEL_REC *channel)
|
||||
{
|
||||
MODULE_CHANNEL_REC *rec;
|
||||
|
||||
g_return_if_fail(channel != NULL);
|
||||
|
||||
rec = g_new0(MODULE_CHANNEL_REC, 1);
|
||||
MODULE_DATA_SET(channel, rec);
|
||||
}
|
||||
|
||||
static void completion_deinit_channel(CHANNEL_REC *channel)
|
||||
{
|
||||
MODULE_CHANNEL_REC *mchannel;
|
||||
|
||||
g_return_if_fail(channel != NULL);
|
||||
|
||||
mchannel = MODULE_DATA(channel);
|
||||
while (mchannel->lastmsgs != NULL)
|
||||
nick_completion_destroy(&mchannel->lastmsgs, mchannel->lastmsgs->data);
|
||||
while (mchannel->lastownmsgs != NULL)
|
||||
nick_completion_destroy(&mchannel->lastownmsgs, mchannel->lastownmsgs->data);
|
||||
|
||||
g_slist_free(mchannel->lastmsgs);
|
||||
g_slist_free(mchannel->lastownmsgs);
|
||||
g_free(mchannel);
|
||||
}
|
||||
|
||||
void irc_completion_init(void)
|
||||
{
|
||||
settings_add_str("completion", "completion_char", ":");
|
||||
settings_add_bool("completion", "completion_auto", FALSE);
|
||||
settings_add_int("completion", "completion_keep_publics", 180);
|
||||
settings_add_int("completion", "completion_keep_ownpublics", 360);
|
||||
settings_add_int("completion", "completion_keep_privates", 10);
|
||||
settings_add_bool("completion", "expand_escapes", FALSE);
|
||||
settings_add_bool("completion", "completion_nicks_lowercase", FALSE);
|
||||
|
||||
complete_tag = g_timeout_add(1000, (GSourceFunc) nick_completion_timeout, NULL);
|
||||
|
||||
signal_add("complete word", (SIGNAL_FUNC) sig_complete_word);
|
||||
signal_add("complete command msg", (SIGNAL_FUNC) sig_complete_msg);
|
||||
signal_add("event privmsg", (SIGNAL_FUNC) event_privmsg);
|
||||
signal_add("command msg", (SIGNAL_FUNC) cmd_msg);
|
||||
signal_add("nicklist remove", (SIGNAL_FUNC) sig_nick_removed);
|
||||
signal_add("nicklist changed", (SIGNAL_FUNC) sig_nick_changed);
|
||||
signal_add("send text", (SIGNAL_FUNC) event_text);
|
||||
signal_add("server connected", (SIGNAL_FUNC) completion_init_server);
|
||||
signal_add("server disconnected", (SIGNAL_FUNC) completion_deinit_server);
|
||||
signal_add_first("channel created", (SIGNAL_FUNC) completion_init_channel);
|
||||
signal_add_last("channel destroyed", (SIGNAL_FUNC) completion_deinit_channel);
|
||||
}
|
||||
|
||||
void irc_completion_deinit(void)
|
||||
{
|
||||
g_source_remove(complete_tag);
|
||||
|
||||
signal_remove("complete word", (SIGNAL_FUNC) sig_complete_word);
|
||||
signal_remove("complete command msg", (SIGNAL_FUNC) sig_complete_msg);
|
||||
signal_remove("event privmsg", (SIGNAL_FUNC) event_privmsg);
|
||||
signal_remove("command msg", (SIGNAL_FUNC) cmd_msg);
|
||||
signal_remove("nicklist remove", (SIGNAL_FUNC) sig_nick_removed);
|
||||
signal_remove("nicklist changed", (SIGNAL_FUNC) sig_nick_changed);
|
||||
signal_remove("send text", (SIGNAL_FUNC) event_text);
|
||||
signal_remove("server connected", (SIGNAL_FUNC) completion_init_server);
|
||||
signal_remove("server disconnected", (SIGNAL_FUNC) completion_deinit_server);
|
||||
signal_remove("channel created", (SIGNAL_FUNC) completion_init_channel);
|
||||
signal_remove("channel destroyed", (SIGNAL_FUNC) completion_deinit_channel);
|
||||
}
|
@ -1,17 +1,3 @@
|
||||
#include "common.h"
|
||||
|
||||
#define MODULE_NAME "fe-common/irc"
|
||||
|
||||
typedef struct {
|
||||
time_t time;
|
||||
char *nick;
|
||||
} LAST_MSG_REC;
|
||||
|
||||
typedef struct {
|
||||
GSList *lastmsgs; /* List of nicks who last send you msg */
|
||||
} MODULE_SERVER_REC;
|
||||
|
||||
typedef struct {
|
||||
GSList *lastmsgs; /* List of nicks who last send message */
|
||||
GSList *lastownmsgs; /* List of nicks who last send message to you */
|
||||
} MODULE_CHANNEL_REC;
|
||||
|
Loading…
Reference in New Issue
Block a user