changeset 11287:fb6e85c55fb8

[gaim-migrate @ 13484] Refactor the idle / away prefs a little bit. Hopefully this will prevent some confusion. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Wed, 17 Aug 2005 04:25:57 +0000
parents 0c2d1b4b1351
children a4ce03725025
files src/gtkprefs.c src/idle.c
diffstat 2 files changed, 36 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkprefs.c	Wed Aug 17 03:22:23 2005 +0000
+++ b/src/gtkprefs.c	Wed Aug 17 04:25:57 2005 +0000
@@ -1781,9 +1781,8 @@
 		NULL);
 
 	vbox = gaim_gtk_make_frame (ret, _("Idle"));
-	dd = gaim_gtk_prefs_dropdown(vbox, _("Idle _time reporting:"),
-			GAIM_PREF_STRING, "/gaim/gtk/idle/reporting_method",
-			_("None"), "none",
+	dd = gaim_gtk_prefs_dropdown(vbox, _("Idle _Tracking:"),
+			GAIM_PREF_STRING, "/gaim/gtk/idle/method",
 			_("Gaim usage"), "gaim",
 #ifdef USE_SCREENSAVER
 #ifndef _WIN32
@@ -1794,6 +1793,9 @@
 #endif
 			NULL);
 
+	button = gaim_gtk_prefs_checkbox(_("_Report idle time"),
+			"/gaim/gtk/idle/report", vbox);
+
 	gtk_size_group_add_widget(sg, dd);
 	gtk_misc_set_alignment(GTK_MISC(dd), 0, 0.5);
 
@@ -2249,7 +2251,14 @@
 
 	/* Idle */
 	gaim_prefs_add_none("/gaim/gtk/idle");
-	gaim_prefs_add_string("/gaim/gtk/idle/reporting_method", "system");
+	gaim_prefs_add_string("/gaim/gtk/idle/method",
+#ifdef USE_SCREENSAVER
+		"system"
+#else
+		"gaim"
+#endif
+	);
+	gaim_prefs_add_bool("/gaim/gtk/idle/report", TRUE);
 
 	/* Plugins */
 	gaim_prefs_add_none("/gaim/gtk/plugins");
@@ -2271,6 +2280,7 @@
 }
 
 void gaim_gtk_prefs_update_old() {
+	const char *idle_method;
 	/* Rename some old prefs */
 	gaim_prefs_rename("/gaim/gtk/logging/log_ims", "/core/logging/log_ims");
 	gaim_prefs_rename("/gaim/gtk/logging/log_chats", "/core/logging/log_chats");
@@ -2287,6 +2297,20 @@
 	gaim_prefs_rename_boolean_toggle("/gaim/gtk/conversations/ignore_formatting",
 									 "/gaim/gtk/conversations/show_incoming_formatting");
 
+	gaim_prefs_rename("/gaim/gtk/idle/reporting_method",
+			"/gaim/gtk/idle/method");
+	idle_method = gaim_prefs_get_string("/gaim/gtk/idle/method");
+	if (idle_method == NULL || !strcmp("none", idle_method)) {
+		gaim_prefs_set_string("/gaim/gtk/idle/method",
+#ifdef USE_SCREENSAVER
+			"system"
+#else
+			"gaim"
+#endif
+		);
+		gaim_prefs_set_bool("/gaim/gtk/idle/report", FALSE);
+	}
+
 	/* Remove some no-longer-used prefs */
 	gaim_prefs_remove("/gaim/gtk/blist/auto_expand_contacts");
 	gaim_prefs_remove("/gaim/gtk/blist/button_style");
--- a/src/idle.c	Wed Aug 17 03:22:23 2005 +0000
+++ b/src/idle.c	Wed Aug 17 04:25:57 2005 +0000
@@ -114,7 +114,8 @@
 check_idle(gpointer data)
 {
 	GaimConnection *gc = data;
-	const char *report_idle;
+	gboolean report_idle;
+	const char *idle_method;
 	GaimAccount *account;
 	time_t t;
 	int idle_time;
@@ -125,10 +126,11 @@
 
 	time(&t);
 
-	report_idle = gaim_prefs_get_string("/gaim/gtk/idle/reporting_method");
+	idle_method = gaim_prefs_get_string("/gaim/gtk/idle/method");
+	report_idle = gaim_prefs_get_bool("/gaim/gtk/idle/report");
 
 #ifdef USE_SCREENSAVER
-	if (report_idle != NULL && !strcmp(report_idle, "system"))
+	if (idle_method != NULL && !strcmp(idle_method, "system"))
 		idle_time = get_idle_time_from_system();
 	else
 #endif /* USE_SCREENSAVER */
@@ -173,24 +175,14 @@
 		/* Need to set this connection to available here */
 	}
 
-	/*
-	 * If we're not reporting idle times to the server, still use Gaim
-	 * usage for auto-away, but quit here so we don't report to the 
-	 * server.
-	 *
-	 * Hmm.  What if _while_ we're idle we toggle the pref for reporting
-	 * idle time to the server?  We would never become unidle...
-	 */
-	if (report_idle != NULL && !strcmp(report_idle, "none"))
-		return TRUE;
-
-	if (idle_time >= IDLEMARK && !gc->is_idle) {
+	/* 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 (idle_time < IDLEMARK && gc->is_idle) {
+	} 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);