| 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(); |
| 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 } |