comparison src/idle.c @ 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 3232e1a33899
children bf6ba37db13b
comparison
equal deleted inserted replaced
11286:0c2d1b4b1351 11287:fb6e85c55fb8
112 */ 112 */
113 gint 113 gint
114 check_idle(gpointer data) 114 check_idle(gpointer data)
115 { 115 {
116 GaimConnection *gc = data; 116 GaimConnection *gc = data;
117 const char *report_idle; 117 gboolean report_idle;
118 const char *idle_method;
118 GaimAccount *account; 119 GaimAccount *account;
119 time_t t; 120 time_t t;
120 int idle_time; 121 int idle_time;
121 122
122 account = gaim_connection_get_account(gc); 123 account = gaim_connection_get_account(gc);
123 124
124 gaim_signal_emit(gaim_blist_get_handle(), "update-idle"); 125 gaim_signal_emit(gaim_blist_get_handle(), "update-idle");
125 126
126 time(&t); 127 time(&t);
127 128
128 report_idle = gaim_prefs_get_string("/gaim/gtk/idle/reporting_method"); 129 idle_method = gaim_prefs_get_string("/gaim/gtk/idle/method");
130 report_idle = gaim_prefs_get_bool("/gaim/gtk/idle/report");
129 131
130 #ifdef USE_SCREENSAVER 132 #ifdef USE_SCREENSAVER
131 if (report_idle != NULL && !strcmp(report_idle, "system")) 133 if (idle_method != NULL && !strcmp(idle_method, "system"))
132 idle_time = get_idle_time_from_system(); 134 idle_time = get_idle_time_from_system();
133 else 135 else
134 #endif /* USE_SCREENSAVER */ 136 #endif /* USE_SCREENSAVER */
135 idle_time = t - gc->last_sent_time; 137 idle_time = t - gc->last_sent_time;
136 138
171 173
172 /* XXX STATUS AWAY CORE/UI */ 174 /* XXX STATUS AWAY CORE/UI */
173 /* Need to set this connection to available here */ 175 /* Need to set this connection to available here */
174 } 176 }
175 177
176 /* 178 /* Deal with reporting idleness to the server, if appropriate */
177 * If we're not reporting idle times to the server, still use Gaim 179 if (report_idle && idle_time >= IDLEMARK && !gc->is_idle) {
178 * usage for auto-away, but quit here so we don't report to the
179 * server.
180 *
181 * Hmm. What if _while_ we're idle we toggle the pref for reporting
182 * idle time to the server? We would never become unidle...
183 */
184 if (report_idle != NULL && !strcmp(report_idle, "none"))
185 return TRUE;
186
187 if (idle_time >= IDLEMARK && !gc->is_idle) {
188 gaim_debug_info("idle", "Setting %s idle %d seconds\n", 180 gaim_debug_info("idle", "Setting %s idle %d seconds\n",
189 gaim_account_get_username(account), idle_time); 181 gaim_account_get_username(account), idle_time);
190 serv_set_idle(gc, idle_time); 182 serv_set_idle(gc, idle_time);
191 gc->is_idle = 1; 183 gc->is_idle = 1;
192 /* LOG system_log(log_idle, gc, NULL, OPT_LOG_BUDDY_IDLE | OPT_LOG_MY_SIGNON); */ 184 /* LOG system_log(log_idle, gc, NULL, OPT_LOG_BUDDY_IDLE | OPT_LOG_MY_SIGNON); */
193 } else if (idle_time < IDLEMARK && gc->is_idle) { 185 } else if ((!report_idle || idle_time < IDLEMARK) && gc->is_idle) {
194 gaim_debug_info("idle", "Setting %s unidle\n", 186 gaim_debug_info("idle", "Setting %s unidle\n",
195 gaim_account_get_username(account)); 187 gaim_account_get_username(account));
196 serv_touch_idle(gc); 188 serv_touch_idle(gc);
197 /* LOG system_log(log_unidle, gc, NULL, OPT_LOG_BUDDY_IDLE | OPT_LOG_MY_SIGNON); */ 189 /* LOG system_log(log_unidle, gc, NULL, OPT_LOG_BUDDY_IDLE | OPT_LOG_MY_SIGNON); */
198 } 190 }