mirror of
https://github.com/irssi/irssi.git
synced 2026-08-11 04:43:34 +02:00
Moved rewritten server redirection code from core to irc. This new code
should be able to do the redirecting a lot more error-proof. Changed lag-checking to use PINGs instead of NOTIFYs. This breaks scripts using redirection. Hopefully this doesn't break too much things in irssi :) git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1980 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
712f3b383d
commit
850cf993eb
28 changed files with 908 additions and 786 deletions
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
#define MODULE_NAME "irc/notifylist"
|
||||
|
||||
#define ISON_EVENT "event 303"
|
||||
|
||||
typedef struct {
|
||||
char *nick;
|
||||
char *user, *host, *realname, *awaymsg;
|
||||
|
|
@ -22,6 +20,8 @@ typedef struct {
|
|||
} NOTIFY_NICK_REC;
|
||||
|
||||
typedef struct {
|
||||
int ison_count; /* number of ISON requests sent */
|
||||
|
||||
GSList *notify_users; /* NOTIFY_NICK_REC's of notifylist people who are in IRC */
|
||||
GSList *ison_tempusers; /* Temporary list for saving /ISON events.. */
|
||||
} MODULE_SERVER_REC;
|
||||
|
|
|
|||
|
|
@ -81,28 +81,19 @@ NOTIFY_NICK_REC *notify_nick_find(IRC_SERVER_REC *server, const char *nick)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int is_ison_queue_empty(IRC_SERVER_REC *server)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
tmp = server_redirect_getqueue((SERVER_REC *) server, ISON_EVENT, NULL);
|
||||
for (; tmp != NULL; tmp = tmp->next) {
|
||||
REDIRECT_REC *rec = tmp->data;
|
||||
|
||||
if (strcmp(rec->name, "notifylist event") == 0)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void ison_send(IRC_SERVER_REC *server, GString *cmd)
|
||||
{
|
||||
MODULE_SERVER_REC *mserver;
|
||||
|
||||
mserver = MODULE_DATA(server);
|
||||
mserver->ison_count++;
|
||||
|
||||
g_string_truncate(cmd, cmd->len-1);
|
||||
g_string_prepend(cmd, "ISON :");
|
||||
|
||||
server_redirect_event(server, "ison", NULL, -1, NULL,
|
||||
"event 303", "notifylist event", NULL);
|
||||
irc_send_cmd(server, cmd->str);
|
||||
server_redirect_event((SERVER_REC *) server, NULL, 1, ISON_EVENT, "notifylist event", -1, NULL);
|
||||
|
||||
g_string_truncate(cmd, 0);
|
||||
}
|
||||
|
|
@ -111,6 +102,7 @@ static void ison_send(IRC_SERVER_REC *server, GString *cmd)
|
|||
notify list is in IRC */
|
||||
static void notifylist_timeout_server(IRC_SERVER_REC *server)
|
||||
{
|
||||
MODULE_SERVER_REC *mserver;
|
||||
GSList *tmp;
|
||||
GString *cmd;
|
||||
char *nick, *ptr;
|
||||
|
|
@ -121,7 +113,8 @@ static void notifylist_timeout_server(IRC_SERVER_REC *server)
|
|||
if (!IS_IRC_SERVER(server))
|
||||
return;
|
||||
|
||||
if (!is_ison_queue_empty(server)) {
|
||||
mserver = MODULE_DATA(server);
|
||||
if (mserver->ison_count > 0) {
|
||||
/* still not received all replies to previous /ISON commands.. */
|
||||
return;
|
||||
}
|
||||
|
|
@ -184,16 +177,13 @@ static void whois_send(IRC_SERVER_REC *server, char *nicks)
|
|||
for (p = str+strlen(nicks)+1; *p != '\0'; p++)
|
||||
if (*p == ',') *p = ' ';
|
||||
|
||||
server_redirect_event((SERVER_REC *) server, str, 2,
|
||||
"event 318", "notifylist event whois end", 1,
|
||||
"event 402", "event empty", 1,
|
||||
"event 401", "event empty", 1,
|
||||
"event 311", "notifylist event whois", 1,
|
||||
"event 301", "notifylist event whois away", 1,
|
||||
"event 312", "event empty", 1,
|
||||
"event 313", "event empty", 1,
|
||||
"event 317", "notifylist event whois idle", 1,
|
||||
"event 319", "event empty", 1, NULL);
|
||||
server_redirect_event(server, "whois", str, FALSE,
|
||||
"notifylist event whois end",
|
||||
"event 318", "notifylist event whois end",
|
||||
"event 311", "notifylist event whois",
|
||||
"event 301", "notifylist event whois away",
|
||||
"event 317", "notifylist event whois idle",
|
||||
"", "event empty", NULL);
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
|
|
@ -311,7 +301,7 @@ static void event_ison(IRC_SERVER_REC *server, const char *data)
|
|||
mserver = MODULE_DATA(server);
|
||||
ison_save_users(mserver, online);
|
||||
|
||||
if (!is_ison_queue_empty(server)) {
|
||||
if (--mserver->ison_count > 0) {
|
||||
/* wait for the rest of the /ISON replies */
|
||||
g_free(params);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -144,8 +144,10 @@ static void event_whois_end(IRC_SERVER_REC *server, const char *data)
|
|||
|
||||
if (event != NULL) {
|
||||
signal_emit(event, 6, server, rec->nick,
|
||||
rec->user, rec->host,
|
||||
rec->realname, rec->awaymsg);
|
||||
rec->user != NULL ? rec->user : "??",
|
||||
rec->host != NULL ? rec->host : "??",
|
||||
rec->realname != NULL ? rec->realname : "??",
|
||||
rec->awaymsg);
|
||||
}
|
||||
rec->idle_ok = notify->idle_check_time <= 0 ||
|
||||
rec->idle_time <= notify->idle_check_time;
|
||||
|
|
|
|||
|
|
@ -196,8 +196,6 @@ static void notifylist_init_server(IRC_SERVER_REC *server)
|
|||
|
||||
rec = g_new0(MODULE_SERVER_REC,1 );
|
||||
MODULE_DATA_SET(server, rec);
|
||||
|
||||
server_redirect_init((SERVER_REC *) server, "command ison", 1, ISON_EVENT, NULL);
|
||||
}
|
||||
|
||||
static void notifylist_deinit_server(IRC_SERVER_REC *server)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue