|
From: <dat...@us...> - 2006-09-09 19:39:36
|
Revision: 17201
http://svn.sourceforge.net/gaim/?rev=17201&view=rev
Author: datallah
Date: 2006-09-09 12:39:31 -0700 (Sat, 09 Sep 2006)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/libgaim/protocols/irc/cmds.c
trunk/libgaim/protocols/irc/irc.c
trunk/libgaim/protocols/irc/irc.h
trunk/libgaim/protocols/irc/parse.c
Modified: trunk/libgaim/protocols/irc/cmds.c
===================================================================
--- trunk/libgaim/protocols/irc/cmds.c 2006-09-09 19:31:45 UTC (rev 17200)
+++ trunk/libgaim/protocols/irc/cmds.c 2006-09-09 19:39:31 UTC (rev 17201)
@@ -1,10 +1,10 @@
/**
* @file cmds.c
- *
+ *
* gaim
*
* Copyright (C) 2003, Ethan Blanton <ebl...@cs...>
- *
+ *
* 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
@@ -336,10 +336,14 @@
stamp = g_strdup_printf("\001PING %lu\001", time(NULL));
buf = irc_format(irc, "vn:", "PRIVMSG", args[0], stamp);
g_free(stamp);
- } else {
+ } else if (target) {
stamp = g_strdup_printf("%s %lu", target, time(NULL));
buf = irc_format(irc, "v:", "PING", stamp);
g_free(stamp);
+ } else {
+ stamp = g_strdup_printf("%lu", time(NULL));
+ buf = irc_format(irc, "vv", "PING", stamp);
+ g_free(stamp);
}
irc_send(irc, buf);
g_free(buf);
Modified: trunk/libgaim/protocols/irc/irc.c
===================================================================
--- trunk/libgaim/protocols/irc/irc.c 2006-09-09 19:31:45 UTC (rev 17200)
+++ trunk/libgaim/protocols/irc/irc.c 2006-09-09 19:39:31 UTC (rev 17201)
@@ -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 */
Modified: trunk/libgaim/protocols/irc/irc.h
===================================================================
--- trunk/libgaim/protocols/irc/irc.h 2006-09-09 19:31:45 UTC (rev 17200)
+++ trunk/libgaim/protocols/irc/irc.h 2006-09-09 19:39:31 UTC (rev 17201)
@@ -83,6 +83,8 @@
GaimCircBuffer *outbuf;
guint writeh;
+
+ time_t recv_time;
};
struct irc_buddy {
Modified: trunk/libgaim/protocols/irc/parse.c
===================================================================
--- trunk/libgaim/protocols/irc/parse.c 2006-09-09 19:31:45 UTC (rev 17200)
+++ trunk/libgaim/protocols/irc/parse.c 2006-09-09 19:39:31 UTC (rev 17201)
@@ -533,6 +533,8 @@
char *cur, *end, *tmp, *from, *msgname, *fmt, **args, *msg;
guint i;
+ irc->recv_time = time(NULL);
+
if (!strncmp(input, "PING ", 5)) {
msg = irc_format(irc, "vv", "PONG", input + 5);
irc_send(irc, msg);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|