comparison libpurple/idle.c @ 18050:2f9eabdc6011

propagate from branch 'im.pidgin.pidgin' (head dcdd8dc5d40cafef802a88f3f713ee1589bc9c41) to branch 'im.pidgin.pidgin.2.1.0' (head b13966c1f1b76ef136a61969fc8bcc68f02b138c)
author Sean Egan <seanegan@gmail.com>
date Wed, 06 Jun 2007 00:23:41 +0000
parents 678d78b7fa34 ac504f643092
children 4ca97b26a8fb
comparison
equal deleted inserted replaced
18047:82d68fedbd77 18050:2f9eabdc6011
90 purple_account_get_username(account)); 90 purple_account_get_username(account));
91 purple_presence_set_idle(presence, FALSE, 0); 91 purple_presence_set_idle(presence, FALSE, 0);
92 } 92 }
93 93
94 94
95 static int no_away = 0; 95 static gboolean no_away = FALSE;
96 static gint time_until_next_idle_event; 96 static gint time_until_next_idle_event;
97 /* 97 /*
98 * This function should be called when you think your idle state 98 * This function should be called when you think your idle state
99 * may have changed. Maybe you're over the 10-minute mark and 99 * may have changed. Maybe you're over the 10-minute mark and
100 * Purple should start reporting idle time to the server. Maybe 100 * Purple should start reporting idle time to the server. Maybe
116 check_idleness(void) 116 check_idleness(void)
117 { 117 {
118 time_t time_idle; 118 time_t time_idle;
119 gboolean auto_away; 119 gboolean auto_away;
120 const gchar *idle_reporting; 120 const gchar *idle_reporting;
121 gboolean report_idle; 121 gboolean report_idle = TRUE;
122 GList *l;
123 gint away_seconds = 0; 122 gint away_seconds = 0;
124 gint idle_recheck_interval = 0; 123 gint idle_recheck_interval = 0;
125 124
126 purple_signal_emit(purple_blist_get_handle(), "update-idle"); 125 purple_signal_emit(purple_blist_get_handle(), "update-idle");
127 126
128 idle_reporting = purple_prefs_get_string("/purple/away/idle_reporting"); 127 idle_reporting = purple_prefs_get_string("/purple/away/idle_reporting");
129 report_idle = TRUE; 128 auto_away = purple_prefs_get_bool("/purple/away/away_when_idle");
129
130 if (!strcmp(idle_reporting, "system") && 130 if (!strcmp(idle_reporting, "system") &&
131 (idle_ui_ops != NULL) && (idle_ui_ops->get_time_idle != NULL)) 131 (idle_ui_ops != NULL) && (idle_ui_ops->get_time_idle != NULL))
132 { 132 {
133 /* Use system idle time (mouse or keyboard movement, etc.) */ 133 /* Use system idle time (mouse or keyboard movement, etc.) */
134 time_idle = idle_ui_ops->get_time_idle(); 134 time_idle = idle_ui_ops->get_time_idle();
143 else 143 else
144 { 144 {
145 /* Don't report idle time */ 145 /* Don't report idle time */
146 time_idle = 0; 146 time_idle = 0;
147 report_idle = FALSE; 147 report_idle = FALSE;
148 } 148
149 149 /* If we're not reporting idle, we can still do auto-away.
150 /* Auto-away stuff */ 150 * First try "system" and if that isn't possible, use "purple" */
151 auto_away = purple_prefs_get_bool("/purple/away/away_when_idle");
152
153 /* If we're not reporting idle, we can still do auto-away.
154 * First try "system" and if that isn't possible, use "purple" */
155 if (!report_idle)
156 {
157 if (auto_away) 151 if (auto_away)
158 { 152 {
159 if ((idle_ui_ops != NULL) && (idle_ui_ops->get_time_idle != NULL)) 153 if ((idle_ui_ops != NULL) && (idle_ui_ops->get_time_idle != NULL))
160 { 154 {
161 time_idle = idle_ui_ops->get_time_idle(); 155 time_idle = idle_ui_ops->get_time_idle();
170 else 164 else
171 { 165 {
172 if (!no_away) 166 if (!no_away)
173 { 167 {
174 purple_savedstatus_set_idleaway(FALSE); 168 purple_savedstatus_set_idleaway(FALSE);
175 no_away = 1; 169 no_away = TRUE;
176 } 170 }
177 time_until_next_idle_event = 0; 171 time_until_next_idle_event = 0;
178 return; 172 return;
179 } 173 }
180 } 174 }
190 away_seconds = 60 * purple_prefs_get_int("/purple/away/mins_before_away"); 184 away_seconds = 60 * purple_prefs_get_int("/purple/away/mins_before_away");
191 185
192 if (auto_away && time_idle > away_seconds) 186 if (auto_away && time_idle > away_seconds)
193 { 187 {
194 purple_savedstatus_set_idleaway(TRUE); 188 purple_savedstatus_set_idleaway(TRUE);
195 no_away = 0; 189 no_away = FALSE;
196 } 190 }
197 else if (!no_away && time_idle < away_seconds) 191 else if (!no_away && time_idle < away_seconds)
198 { 192 {
199 no_away = 1; 193 no_away = TRUE;
200 purple_savedstatus_set_idleaway(FALSE); 194 purple_savedstatus_set_idleaway(FALSE);
201 if (time_until_next_idle_event == 0 || (away_seconds - time_idle) < time_until_next_idle_event) 195 if (time_until_next_idle_event == 0 || (away_seconds - time_idle) < time_until_next_idle_event)
202 time_until_next_idle_event = away_seconds - time_idle; 196 time_until_next_idle_event = away_seconds - time_idle;
203 } 197 }
204 198
205 /* Idle reporting stuff */ 199 /* Idle reporting stuff */
206 if (report_idle && (time_idle >= IDLEMARK)) 200 if (report_idle && (time_idle >= IDLEMARK))
207 { 201 {
202 GList *l;
208 for (l = purple_connections_get_all(); l != NULL; l = l->next) 203 for (l = purple_connections_get_all(); l != NULL; l = l->next)
209 { 204 {
210 PurpleConnection *gc = l->data; 205 PurpleConnection *gc = l->data;
211 set_account_idle(purple_connection_get_account(gc), time_idle); 206 set_account_idle(purple_connection_get_account(gc), time_idle);
212 } 207 }