diff options
author | Timo Sirainen <cras@irssi.org> | 2001-11-11 18:59:19 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-11-11 18:59:19 +0000 |
commit | 850cf993eb8d5e20b9b845e42e4bdae1a6cae81f (patch) | |
tree | 76ac7694abd05394ae84e10763b406be88ad86aa /src/irc/notifylist | |
parent | 712f3b383da947f5c565fba3695dbcd02136ce4b (diff) | |
download | irssi-850cf993eb8d5e20b9b845e42e4bdae1a6cae81f.zip |
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
Diffstat (limited to 'src/irc/notifylist')
-rw-r--r-- | src/irc/notifylist/module.h | 4 | ||||
-rw-r--r-- | src/irc/notifylist/notify-ison.c | 44 | ||||
-rw-r--r-- | src/irc/notifylist/notify-whois.c | 6 | ||||
-rw-r--r-- | src/irc/notifylist/notifylist.c | 2 |
4 files changed, 23 insertions, 33 deletions
diff --git a/src/irc/notifylist/module.h b/src/irc/notifylist/module.h index 546201f6..d88058e4 100644 --- a/src/irc/notifylist/module.h +++ b/src/irc/notifylist/module.h @@ -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; diff --git a/src/irc/notifylist/notify-ison.c b/src/irc/notifylist/notify-ison.c index 8096c5a9..c515b4d7 100644 --- a/src/irc/notifylist/notify-ison.c +++ b/src/irc/notifylist/notify-ison.c @@ -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) +static void ison_send(IRC_SERVER_REC *server, GString *cmd) { - 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; - } + MODULE_SERVER_REC *mserver; - return TRUE; -} + mserver = MODULE_DATA(server); + mserver->ison_count++; -static void ison_send(IRC_SERVER_REC *server, GString *cmd) -{ 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; diff --git a/src/irc/notifylist/notify-whois.c b/src/irc/notifylist/notify-whois.c index eb7becd2..c3786294 100644 --- a/src/irc/notifylist/notify-whois.c +++ b/src/irc/notifylist/notify-whois.c @@ -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; diff --git a/src/irc/notifylist/notifylist.c b/src/irc/notifylist/notifylist.c index 3d050a9d..0d2b5c21 100644 --- a/src/irc/notifylist/notifylist.c +++ b/src/irc/notifylist/notifylist.c @@ -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) |