changeset 11907:d2db6426c88a

[gaim-migrate @ 14198] sf patch #1342817, from Evan Schoenberg "As discussed in #gaim, this patch removes idle.c and replaces it with gtkidle.c and gtkidle.h. The attached diff removes the idle management from its various hiding places in connection.c, server.c, and gaim.h. The plugins Changelog.API is appropriately updated. The new gtkidle files are attached; idle.c should be removed from CVS." committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 30 Oct 2005 23:00:47 +0000
parents 8913546c6a4e
children 34ea75bdd0c9
files plugins/ChangeLog.API plugins/perl/common/Server.xs src/Makefile.am src/Makefile.mingw src/connection.c src/gaim.h src/gtkidle.c src/gtkidle.h src/gtkmain.c src/idle.c src/server.c src/server.h
diffstat 12 files changed, 337 insertions(+), 239 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/ChangeLog.API	Sun Oct 30 20:20:38 2005 +0000
+++ b/plugins/ChangeLog.API	Sun Oct 30 23:00:47 2005 +0000
@@ -48,8 +48,10 @@
 		conversation can have multiple logs at once
 	* gaim_conv_chat_add_user, added extra_msgs list
 	* gaim_notify_userinfo, removed primary and secondary parameters
-	* GaimNotifyUiOps.notify_userinfo: removed title, primary, and secondary
-		parameters
+	* GaimNotifyUiOps.notify_userinfo: removed title, primary, and
+	  secondary parameters
+	* Idle timers are now added and removed in gtkidle.c in response
+	  to the signed-on and signed-off signals
 
 	Removed:
 	* gaim_gtk_sound_{get,set}_mute() (replaced by the /gaim/gtk/sound/mute
@@ -85,6 +87,7 @@
 	* serv_remove_buddy(); use gaim_account_remove_buddy() instead
 	* serv_remove_buddies(); use gaim_account_remove_buddies() instead
 	* serv_change_passwd(); use gaim_account_change_password() instead
+	* serv_touch_idle(): use gaim_gtk_check_idle() instead
 	* GaimGtkImPane->a_virgin
 
 	Added:
--- a/plugins/perl/common/Server.xs	Sun Oct 30 20:20:38 2005 +0000
+++ b/plugins/perl/common/Server.xs	Sun Oct 30 23:00:47 2005 +0000
@@ -223,7 +223,3 @@
 serv_set_permit_deny(con)
 	Gaim::Connection con  
 
-void 
-serv_touch_idle(con)
-	Gaim::Connection con 
-
--- a/src/Makefile.am	Sun Oct 30 20:20:38 2005 +0000
+++ b/src/Makefile.am	Sun Oct 30 23:00:47 2005 +0000
@@ -255,6 +255,7 @@
 	gtkeventloop.c \
 	gtkexpander.c \
 	gtkft.c \
+	gtkidle.c \
 	gtkimhtml.c \
 	gtkimhtmltoolbar.c \
 	gtklog.c \
@@ -276,7 +277,6 @@
 	gtkthemes.c \
 	gtkutils.c \
 	gtkwhiteboard.c \
-	idle.c \
 	session.c
 
 gaim_headers = \
@@ -301,6 +301,7 @@
 	gtkexpander.h \
 	gtkft.h \
 	gtkgaim.h \
+	gtkidle.h \
 	gtkimhtml.h \
 	gtkimhtmltoolbar.h \
 	gtklog.h \
--- a/src/Makefile.mingw	Sun Oct 30 20:20:38 2005 +0000
+++ b/src/Makefile.mingw	Sun Oct 30 23:00:47 2005 +0000
@@ -105,6 +105,7 @@
 			gtkeventloop.c \
 			gtkexpander.c \
 			gtkft.c \
+			gtkidle.c \
 			gtkimhtml.c \
 			gtkimhtmltoolbar.c \
 			gtklog.c \
@@ -126,7 +127,6 @@
 			gtkthemes.c \
 			gtkutils.c \
 			gtkwhiteboard.c \
-			idle.c \
 			imgstore.c \
 			log.c \
 			mime.c \
--- a/src/connection.c	Sun Oct 30 20:20:38 2005 +0000
+++ b/src/connection.c	Sun Oct 30 23:00:47 2005 +0000
@@ -178,10 +178,6 @@
 		gaim_conv_chat_left(GAIM_CONV_CHAT(b));
 	}
 
-	if (gc->idle_timer > 0)
-		gaim_timeout_remove(gc->idle_timer);
-	gc->idle_timer = 0;
-
 	update_keepalive(gc, FALSE);
 
 	if (gc->prpl != NULL)
@@ -318,12 +314,6 @@
 
 		if (gaim_account_get_user_info(account) != NULL)
 			serv_set_info(gc, gaim_account_get_user_info(account));
-
-		if (gc->idle_timer > 0)
-			gaim_timeout_remove(gc->idle_timer);
-
-		gc->idle_timer = gaim_timeout_add(20000, check_idle, gc);
-		serv_touch_idle(gc);
 	}
 	else if (gc->state == GAIM_DISCONNECTED) {
 		GaimAccount *account = gaim_connection_get_account(gc);
--- a/src/gaim.h	Sun Oct 30 20:20:38 2005 +0000
+++ b/src/gaim.h	Sun Oct 30 23:00:47 2005 +0000
@@ -25,7 +25,4 @@
 
 #define XPATCH BAD /* Because Kalla Said So */
 
-/* Functions in idle.c */
-extern gint check_idle(gpointer);
-
 #endif /* _GAIM_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gtkidle.c	Sun Oct 30 23:00:47 2005 +0000
@@ -0,0 +1,265 @@
+/*
+ * gaim
+ *
+ * Gaim is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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 "internal.h"
+
+#ifdef USE_SCREENSAVER
+# ifndef _WIN32
+#  include <X11/Xlib.h>
+#  include <X11/Xutil.h>
+#  include <X11/extensions/scrnsaver.h>
+#  include <gdk/gdkx.h>
+# else
+#  include "idletrack.h"
+# endif
+#endif /* USE_SCREENSAVER */
+
+#include "connection.h"
+#include "debug.h"
+#include "log.h"
+#include "prefs.h"
+#include "savedstatuses.h"
+#include "signals.h"
+
+#define IDLEMARK 600	/* 10 minutes! */
+#define IDLE_CHECK_INTERVAL 20000 /* 20 seconds */
+
+typedef enum
+{
+	GAIM_IDLE_NOT_AWAY = 0,
+	GAIM_IDLE_AUTO_AWAY,
+	GAIM_IDLE_AWAY_BUT_NOT_AUTO_AWAY
+
+} GaimAutoAwayState;
+
+#ifdef USE_SCREENSAVER
+/**
+ * Get the number of seconds the user has been idle.  In Unix-world
+ * this is based on the X Windows usage.  In MS Windows this is based
+ * on keyboard/mouse usage.
+ *
+ * In Debian bug #271639, jwz says:
+ *
+ * Gaim should simply ask xscreensaver how long the user has been idle:
+ *   % xscreensaver-command -time
+ *   XScreenSaver 4.18: screen blanked since Tue Sep 14 14:10:45 2004
+ *
+ * Or you can monitor the _SCREENSAVER_STATUS property on root window #0.
+ * Element 0 is the status (0, BLANK, LOCK), element 1 is the time_t since
+ * the last state change, and subsequent elements are which hack is running
+ * on the various screens:
+ *   % xprop -f _SCREENSAVER_STATUS 32ac -root _SCREENSAVER_STATUS
+ *   _SCREENSAVER_STATUS(INTEGER) = BLANK, 1095196626, 10, 237
+ *
+ * See watch() in xscreensaver/driver/xscreensaver-command.c.
+ *
+ * @return The number of seconds the user has been idle.
+ */
+static int
+get_idle_time_from_system()
+{
+#ifndef _WIN32
+	static XScreenSaverInfo *mit_info = NULL;
+	int event_base, error_base;
+	if (XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base, &error_base)) {
+		if (mit_info == NULL) {
+			mit_info = XScreenSaverAllocInfo();
+		}
+		XScreenSaverQueryInfo(GDK_DISPLAY(), GDK_ROOT_WINDOW(), mit_info);
+		return (mit_info->idle) / 1000;
+	} else
+		return 0;
+#else
+	return (GetTickCount() - wgaim_get_lastactive()) / 1000;
+#endif
+}
+#endif /* USE_SCREENSAVER */
+
+/*
+ * This function should be called when you think your idle state
+ * may have changed.  Maybe you're over the 10-minute mark and
+ * Gaim should start reporting idle time to the server.  Maybe
+ * you've returned from being idle.  Maybe your auto-away message
+ * should be set.
+ *
+ * There is no harm to calling this many many times, other than
+ * it will be kinda slow.  This is called every 20 seconds by a
+ * timer set when an account logs in.  It is also called when
+ * you send an IM, a chat, etc.
+ *
+ * This function has 3 sections.
+ * 1. Get your idle time.  It will query XScreenSaver or Windows
+ *    or get the Gaim idle time.  Whatever.
+ * 2. Set or unset your auto-away message.
+ * 3. Report your current idle time to the IM server.
+ */
+gint
+gaim_gtk_idle_check(gpointer data)
+{
+	GaimConnection *gc = (GaimConnection *)data;
+	gboolean report_idle;
+	GaimAccount *account;
+	time_t t;
+	int idle_time;
+
+	account = gaim_connection_get_account(gc);
+
+	gaim_signal_emit(gaim_blist_get_handle(), "update-idle");
+
+	time(&t);
+
+	report_idle = gaim_prefs_get_bool("/gaim/gtk/idle/report");
+
+#ifdef USE_SCREENSAVER
+		idle_time = get_idle_time_from_system();
+#else
+		/*
+		 * If Gaim wasn't built with xscreensaver support, then
+		 * fallback to calculating our idle time based on when
+		 * we last sent a message.
+		 */
+		idle_time = t - gc->last_sent_time;
+#endif /* USE_SCREENSAVER */
+
+	/* Should we become auto-away? */
+	if (gaim_prefs_get_bool("/core/away/away_when_idle") &&
+		(idle_time > (60 * gaim_prefs_get_int("/core/away/mins_before_away")))
+		&& (!gc->is_auto_away))
+	{
+		GaimPresence *presence;
+
+		presence = gaim_account_get_presence(account);
+
+		if (gaim_presence_is_available(presence))
+		{
+			const char *idleaway_name;
+			GaimSavedStatus *saved_status;
+
+			gaim_debug_info("idle", "Making %s auto-away\n",
+							gaim_account_get_username(account));
+
+			/* Mark our accounts "away" using the idleaway status */
+			idleaway_name = gaim_prefs_get_string("/core/status/idleaway");
+			saved_status = gaim_savedstatus_find(idleaway_name);
+			if (saved_status)
+				gaim_savedstatus_activate(saved_status);
+
+			gc->is_auto_away = GAIM_IDLE_AUTO_AWAY;
+		} else {
+			gc->is_auto_away = GAIM_IDLE_AWAY_BUT_NOT_AUTO_AWAY;
+		}
+
+	/* Should we return from being auto-away? */
+	} else if (gc->is_auto_away &&
+			idle_time < 60 * gaim_prefs_get_int("/core/away/mins_before_away")) {
+		if (gc->is_auto_away == GAIM_IDLE_AWAY_BUT_NOT_AUTO_AWAY) {
+			gc->is_auto_away = GAIM_IDLE_NOT_AWAY;
+			return TRUE;
+		}
+		gc->is_auto_away = GAIM_IDLE_NOT_AWAY;
+
+		/* XXX STATUS AWAY CORE/UI */
+		/* Need to set this connection to available here */
+	}
+
+	/* Deal with reporting idleness to the server, if appropriate */
+	if (report_idle && idle_time >= IDLEMARK && !gc->is_idle) {
+		gaim_debug_info("idle", "Setting %s idle %d seconds\n",
+				   gaim_account_get_username(account), idle_time);
+		serv_set_idle(gc, idle_time);
+		gc->is_idle = 1;
+		/* LOG	system_log(log_idle, gc, NULL, OPT_LOG_BUDDY_IDLE | OPT_LOG_MY_SIGNON); */
+	} else if ((!report_idle || idle_time < IDLEMARK) && gc->is_idle) {
+		gaim_debug_info("idle", "Setting %s unidle\n",
+				   gaim_account_get_username(account));
+		gc->is_idle = 0;
+		serv_set_idle(gc, 0);
+		/* LOG	system_log(log_unidle, gc, NULL, OPT_LOG_BUDDY_IDLE | OPT_LOG_MY_SIGNON); */
+	}
+
+	return TRUE;
+}
+
+static void
+im_msg_sent_cb(GaimAccount *account, const char *receiver,
+			   const char *message, void *data)
+{
+	GaimConnection	*gc = gaim_account_get_connection(account);
+
+	/* After an IM is sent, check our idle time */
+	gaim_gtk_idle_check(gc);
+}
+
+static void
+remove_idle_timer(GaimConnection *gc)
+{
+	/* Remove any existing idle_timer */
+	if (gc->idle_timer > 0)
+		gaim_timeout_remove(gc->idle_timer);
+	gc->idle_timer = 0;
+}
+
+static void
+connection_disconnected_cb(GaimConnection *gc, gpointer user_data)
+{
+	remove_idle_timer(gc);
+}
+
+static void
+connection_connected_cb(GaimConnection *gc, gpointer user_data)
+{
+	/* Now that we are connected, check for idleness every 20 seconds */
+	remove_idle_timer(gc);
+	gc->idle_timer = gaim_timeout_add(IDLE_CHECK_INTERVAL, gaim_gtk_idle_check, gc);
+
+	/* Immediately update our idleness, in case we connected while idle */
+	gaim_gtk_idle_check(gc);
+}
+
+void *
+gaim_gtk_idle_get_handle()
+{
+	static int handle;
+
+	return &handle;
+}
+
+void
+gaim_gtk_idle_init()
+{
+	gaim_signal_connect(gaim_conversations_get_handle(), "sent-im-msg",
+						gaim_gtk_idle_get_handle(),
+						GAIM_CALLBACK(im_msg_sent_cb), NULL);
+
+	gaim_signal_connect(gaim_connections_get_handle(), "signed-on",
+						gaim_gtk_idle_get_handle(),
+						GAIM_CALLBACK(connection_connected_cb), NULL);
+	gaim_signal_connect(gaim_connections_get_handle(), "signed-off",
+						gaim_gtk_idle_get_handle(),
+						GAIM_CALLBACK(connection_disconnected_cb), NULL);
+}
+
+void
+gaim_gtk_idle_uninit()
+{
+	gaim_signals_disconnect_by_handle(gaim_gtk_idle_get_handle());
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gtkidle.h	Sun Oct 30 23:00:47 2005 +0000
@@ -0,0 +1,54 @@
+/**
+ * @file gtkidle.h GTK+ Idle API
+ * @ingroup gtkui
+ *
+ * gaim
+ *
+ * Gaim is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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
+ */
+#ifndef _GAIM_GTK_IDLE_H_
+#define _GAIM_GTK_IDLE_H_
+
+/**************************************************************************/
+/** @name GTK+ Idle API                                                  */
+/**************************************************************************/
+/*@{*/
+
+
+/**
+ * Initializes the GTK+ idle system.
+ */
+void gaim_gtk_idle_init(void);
+
+/**
+ * Uninitializes the GTK+ idle system.
+ */
+void gaim_gtk_idle_uninit(void);
+
+/**
+ * Check the current idle time, reporting to the server or going auto-away as
+ * appropriate.
+ *
+ * @param gc The GaimConnection* to check
+ */
+gint gaim_gtk_idle_check(gpointer data);
+
+/*@}*/
+
+#endif /* _GAIM_GTK_IDLE_H_ */
--- a/src/gtkmain.c	Sun Oct 30 20:20:38 2005 +0000
+++ b/src/gtkmain.c	Sun Oct 30 23:00:47 2005 +0000
@@ -48,6 +48,7 @@
 #include "gtkdialogs.h"
 #include "gtkeventloop.h"
 #include "gtkft.h"
+#include "gtkidle.h"
 #include "gtknotify.h"
 #include "gtkplugin.h"
 #include "gtkpounce.h"
@@ -267,6 +268,7 @@
 	gaim_gtk_privacy_init();
 	gaim_gtk_xfers_init();
 	gaim_gtk_roomlist_init();
+	gaim_gtk_idle_init();
 }
 
 static void
@@ -293,6 +295,7 @@
 	gaim_gtk_account_uninit();
 	gaim_gtk_xfers_uninit();
 	gaim_gtk_debug_uninit();
+	gaim_gtk_idle_uninit();
 
 	/* and end it all... */
 	gtk_main_quit();
--- a/src/idle.c	Sun Oct 30 20:20:38 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,199 +0,0 @@
-/*
- * gaim
- *
- * Gaim is the legal property of its developers, whose names are too numerous
- * to list here.  Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * 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 "internal.h"
-
-#ifdef USE_SCREENSAVER
-# ifndef _WIN32
-#  include <X11/Xlib.h>
-#  include <X11/Xutil.h>
-#  include <X11/extensions/scrnsaver.h>
-#  include <gdk/gdkx.h>
-# else
-#  include "idletrack.h"
-# endif
-#endif /* USE_SCREENSAVER */
-
-#include "connection.h"
-#include "debug.h"
-#include "log.h"
-#include "prefs.h"
-#include "savedstatuses.h"
-#include "signals.h"
-
-#define IDLEMARK 600	/* 10 minutes! */
-
-typedef enum
-{
-	GAIM_IDLE_NOT_AWAY = 0,
-	GAIM_IDLE_AUTO_AWAY,
-	GAIM_IDLE_AWAY_BUT_NOT_AUTO_AWAY
-
-} GaimAutoAwayState;
-
-#ifdef USE_SCREENSAVER
-/**
- * Get the number of seconds the user has been idle.  In Unix-world
- * this is based on the X Windows usage.  In MS Windows this is based
- * on keyboard/mouse usage.
- *
- * In Debian bug #271639, jwz says:
- *
- * Gaim should simply ask xscreensaver how long the user has been idle:
- *   % xscreensaver-command -time
- *   XScreenSaver 4.18: screen blanked since Tue Sep 14 14:10:45 2004
- *
- * Or you can monitor the _SCREENSAVER_STATUS property on root window #0.
- * Element 0 is the status (0, BLANK, LOCK), element 1 is the time_t since
- * the last state change, and subsequent elements are which hack is running
- * on the various screens:
- *   % xprop -f _SCREENSAVER_STATUS 32ac -root _SCREENSAVER_STATUS
- *   _SCREENSAVER_STATUS(INTEGER) = BLANK, 1095196626, 10, 237
- *
- * See watch() in xscreensaver/driver/xscreensaver-command.c.
- *
- * @return The number of seconds the user has been idle.
- */
-static int
-get_idle_time_from_system()
-{
-#ifndef _WIN32
-	static XScreenSaverInfo *mit_info = NULL;
-	int event_base, error_base;
-	if (XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base, &error_base)) {
-		if (mit_info == NULL) {
-			mit_info = XScreenSaverAllocInfo();
-		}
-		XScreenSaverQueryInfo(GDK_DISPLAY(), GDK_ROOT_WINDOW(), mit_info);
-		return (mit_info->idle) / 1000;
-	} else
-		return 0;
-#else
-	return (GetTickCount() - wgaim_get_lastactive()) / 1000;
-#endif
-}
-#endif /* USE_SCREENSAVER */
-
-/*
- * This function should be called when you think your idle state
- * may have changed.  Maybe you're over the 10-minute mark and
- * Gaim should start reporting idle time to the server.  Maybe
- * you've returned from being idle.  Maybe your auto-away message
- * should be set.
- *
- * There is no harm to calling this many many times, other than
- * it will be kinda slow.  This is called every 20 seconds by a
- * timer set when an account logs in.  It is also called when
- * you send an IM, a chat, etc.
- *
- * This function has 3 sections.
- * 1. Get your idle time.  It will query XScreenSaver or Windows
- *    or get the Gaim idle time.  Whatever.
- * 2. Set or unset your auto-away message.
- * 3. Report your current idle time to the IM server.
- */
-/* TODO: This needs to be namespaced or moved elsewhere. */
-gint
-check_idle(gpointer data)
-{
-	GaimConnection *gc = data;
-	gboolean report_idle;
-	GaimAccount *account;
-	time_t t;
-	int idle_time;
-
-	account = gaim_connection_get_account(gc);
-
-	gaim_signal_emit(gaim_blist_get_handle(), "update-idle");
-
-	time(&t);
-
-	report_idle = gaim_prefs_get_bool("/gaim/gtk/idle/report");
-
-#ifdef USE_SCREENSAVER
-		idle_time = get_idle_time_from_system();
-#else
-		/*
-		 * If Gaim wasn't built with xscreensaver support, then
-		 * fallback to calculating our idle time based on when
-		 * we last sent a message.
-		 */
-		idle_time = t - gc->last_sent_time;
-#endif /* USE_SCREENSAVER */
-
-	/* Should we become auto-away? */
-	if (gaim_prefs_get_bool("/core/away/away_when_idle") &&
-		(idle_time > (60 * gaim_prefs_get_int("/core/away/mins_before_away")))
-		&& (!gc->is_auto_away))
-	{
-		GaimPresence *presence;
-
-		presence = gaim_account_get_presence(account);
-
-		if (gaim_presence_is_available(presence))
-		{
-			const char *idleaway_name;
-			GaimSavedStatus *saved_status;
-
-			gaim_debug_info("idle", "Making %s auto-away\n",
-							gaim_account_get_username(account));
-
-			/* Mark our accounts "away" using the idleaway status */
-			idleaway_name = gaim_prefs_get_string("/core/status/idleaway");
-			saved_status = gaim_savedstatus_find(idleaway_name);
-			if (saved_status)
-				gaim_savedstatus_activate(saved_status);
-
-			gc->is_auto_away = GAIM_IDLE_AUTO_AWAY;
-		} else {
-			gc->is_auto_away = GAIM_IDLE_AWAY_BUT_NOT_AUTO_AWAY;
-		}
-
-	/* Should we return from being auto-away? */
-	} else if (gc->is_auto_away &&
-			idle_time < 60 * gaim_prefs_get_int("/core/away/mins_before_away")) {
-		if (gc->is_auto_away == GAIM_IDLE_AWAY_BUT_NOT_AUTO_AWAY) {
-			gc->is_auto_away = GAIM_IDLE_NOT_AWAY;
-			return TRUE;
-		}
-		gc->is_auto_away = GAIM_IDLE_NOT_AWAY;
-
-		/* XXX STATUS AWAY CORE/UI */
-		/* Need to set this connection to available here */
-	}
-
-	/* Deal with reporting idleness to the server, if appropriate */
-	if (report_idle && idle_time >= IDLEMARK && !gc->is_idle) {
-		gaim_debug_info("idle", "Setting %s idle %d seconds\n",
-				   gaim_account_get_username(account), idle_time);
-		serv_set_idle(gc, idle_time);
-		gc->is_idle = 1;
-		/* LOG	system_log(log_idle, gc, NULL, OPT_LOG_BUDDY_IDLE | OPT_LOG_MY_SIGNON); */
-	} else if ((!report_idle || idle_time < IDLEMARK) && gc->is_idle) {
-		gaim_debug_info("idle", "Setting %s unidle\n",
-				   gaim_account_get_username(account));
-		serv_touch_idle(gc);
-		/* LOG	system_log(log_unidle, gc, NULL, OPT_LOG_BUDDY_IDLE | OPT_LOG_MY_SIGNON); */
-	}
-
-	return TRUE;
-}
--- a/src/server.c	Sun Oct 30 20:20:38 2005 +0000
+++ b/src/server.c	Sun Oct 30 23:00:47 2005 +0000
@@ -41,18 +41,6 @@
 #define SECS_BEFORE_RESENDING_AUTORESPONSE 600
 #define SEX_BEFORE_RESENDING_AUTORESPONSE "Only after you're married"
 
-void serv_touch_idle(GaimConnection *gc)
-{
-	/* Are we idle?  If so, not anymore */
-	if (gc->is_idle > 0) {
-		gc->is_idle = 0;
-		serv_set_idle(gc, 0);
-	}
-	time(&gc->last_sent_time);
-	if (gc->is_auto_away)
-		check_idle(gc);
-}
-
 /* This should return the elapsed time in seconds in which Gaim will not send
  * typing notifications.
  * if it returns zero, it will not send any more typing notifications
@@ -149,8 +137,9 @@
 	if (prpl_info && prpl_info->send_im)
 		val = prpl_info->send_im(gc, name, message, imflags);
 
+	/* Only update the last_sent_time if the user actually sent the message */
 	if (!(imflags & GAIM_CONV_IM_AUTO_RESP))
-		serv_touch_idle(gc);
+		time(&gc->last_sent_time);
 
 	/*
 	 * XXX - If "only auto-reply when away & idle" is set, then shouldn't
@@ -428,18 +417,18 @@
 		prpl_info->chat_whisper(g, id, who, message);
 }
 
-int serv_chat_send(GaimConnection *g, int id, const char *message)
+int serv_chat_send(GaimConnection *gc, int id, const char *message)
 {
 	int val = -EINVAL;
 	GaimPluginProtocolInfo *prpl_info = NULL;
 
-	if (g->prpl != NULL)
-		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
+	if (gc->prpl != NULL)
+		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
 
 	if (prpl_info && prpl_info->chat_send)
-		val = prpl_info->chat_send(g, id, message);
+		val = prpl_info->chat_send(gc, id, message);
 
-	serv_touch_idle(g);
+	time(&gc->last_sent_time);
 
 	return val;
 }
--- a/src/server.h	Sun Oct 30 20:20:38 2005 +0000
+++ b/src/server.h	Sun Oct 30 23:00:47 2005 +0000
@@ -33,7 +33,6 @@
 extern "C" {
 #endif
 
-void serv_touch_idle(GaimConnection *);
 int  serv_send_im(GaimConnection *, const char *, const char *, GaimConvImFlags);
 void serv_get_info(GaimConnection *, const char *);
 void serv_set_idle(GaimConnection *, int);