Mercurial > pidgin
diff libgaim/protocols/irc/irc.c @ 14482:a5c7db7be826
[gaim-migrate @ 17201]
Prevent irc accounts from being disconnected for long periods without us noticing. Use the prpl keepalive cb to ping the server if we haven't received anything in at least 60 seconds.
committer: Tailor Script <tailor@pidgin.im>
| author | Daniel Atallah <daniel.atallah@gmail.com> |
|---|---|
| date | Sat, 09 Sep 2006 19:39:31 +0000 |
| parents | 34de373e45c1 |
| children | 8ed6ef220b2d |
line wrap: on
line diff
--- a/libgaim/protocols/irc/irc.c Sat Sep 09 19:31:45 2006 +0000 +++ b/libgaim/protocols/irc/irc.c Sat Sep 09 19:39:31 2006 +0000 @@ -37,6 +37,8 @@ #include "irc.h" +#define PING_TIMEOUT 60 + static void irc_buddy_append(char *name, struct irc_buddy *ib, GString *string); static const char *irc_blist_icon(GaimAccount *a, GaimBuddy *b); @@ -373,6 +375,8 @@ } g_free(buf); + irc->recv_time = time(NULL); + return TRUE; } @@ -787,6 +791,13 @@ } } +static void irc_keepalive(GaimConnection *gc) +{ + struct irc_conn *irc = gc->proto_data; + if ((time(NULL) - irc->recv_time) > PING_TIMEOUT) + irc_cmd_ping(irc, NULL, NULL, NULL); +} + static GaimPluginProtocolInfo prpl_info = { OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL, @@ -826,7 +837,7 @@ irc_chat_leave, /* chat_leave */ NULL, /* chat_whisper */ irc_chat_send, /* chat_send */ - NULL, /* keepalive */ + irc_keepalive, /* keepalive */ NULL, /* register_user */ NULL, /* get_cb_info */ NULL, /* get_cb_away */
