Mercurial > pidgin
comparison src/idle.c @ 14128:a8a033a89ee0
[gaim-migrate @ 16766]
I'm hoping this will fix a lot of the remaining idle-away problems,
like not correctly returning from idle-away. This change also
causes the gtkstatusbox to show your idle-away status when you are
idle-away.
Please test everything and let me know if there are any problems.
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Tue, 15 Aug 2006 08:22:29 +0000 |
| parents | 9a4b76c288aa |
| children |
comparison
equal
deleted
inserted
replaced
| 14127:9a4b76c288aa | 14128:a8a033a89ee0 |
|---|---|
| 56 static guint idle_timer = 0; | 56 static guint idle_timer = 0; |
| 57 | 57 |
| 58 static time_t last_active_time = 0; | 58 static time_t last_active_time = 0; |
| 59 | 59 |
| 60 static void | 60 static void |
| 61 set_account_autoaway(GaimConnection *gc) | |
| 62 { | |
| 63 GaimAccount *account; | |
| 64 GaimPresence *presence; | |
| 65 GaimStatus *status; | |
| 66 | |
| 67 if (gc->is_auto_away) | |
| 68 /* This account is already auto-away! */ | |
| 69 return; | |
| 70 | |
| 71 account = gaim_connection_get_account(gc); | |
| 72 presence = gaim_account_get_presence(account); | |
| 73 status = gaim_presence_get_active_status(presence); | |
| 74 | |
| 75 if (gaim_status_is_available(status)) | |
| 76 { | |
| 77 GaimSavedStatus *saved_status; | |
| 78 | |
| 79 gaim_debug_info("idle", "Making %s auto-away\n", | |
| 80 gaim_account_get_username(account)); | |
| 81 | |
| 82 saved_status = gaim_savedstatus_get_idleaway(); | |
| 83 gaim_savedstatus_activate_for_account(saved_status, account); | |
| 84 | |
| 85 gc->is_auto_away = GAIM_IDLE_AUTO_AWAY; | |
| 86 } else { | |
| 87 gc->is_auto_away = GAIM_IDLE_AWAY_BUT_NOT_AUTO_AWAY; | |
| 88 } | |
| 89 } | |
| 90 | |
| 91 static void | |
| 92 unset_account_autoaway(GaimConnection *gc) | |
| 93 { | |
| 94 GaimAccount *account; | |
| 95 GaimSavedStatus *saved_status; | |
| 96 | |
| 97 account = gaim_connection_get_account(gc); | |
| 98 | |
| 99 if (!gc->is_auto_away) | |
| 100 /* This account is already not auto-away! */ | |
| 101 return; | |
| 102 | |
| 103 if (gc->is_auto_away == GAIM_IDLE_AWAY_BUT_NOT_AUTO_AWAY) { | |
| 104 gc->is_auto_away = GAIM_IDLE_NOT_AWAY; | |
| 105 } else { | |
| 106 gc->is_auto_away = GAIM_IDLE_NOT_AWAY; | |
| 107 | |
| 108 gaim_debug_info("idle", "%s returning from auto-away\n", | |
| 109 gaim_account_get_username(account)); | |
| 110 | |
| 111 /* Return our account to its previous status */ | |
| 112 saved_status = gaim_savedstatus_get_current(); | |
| 113 gaim_savedstatus_activate_for_account(saved_status, account); | |
| 114 } | |
| 115 } | |
| 116 | |
| 117 static void | |
| 118 set_account_idle(GaimAccount *account, int time_idle) | 61 set_account_idle(GaimAccount *account, int time_idle) |
| 119 { | 62 { |
| 120 GaimPresence *presence; | 63 GaimPresence *presence; |
| 121 | 64 |
| 122 presence = gaim_account_get_presence(account); | 65 presence = gaim_account_get_presence(account); |
| 201 /* Auto-away stuff */ | 144 /* Auto-away stuff */ |
| 202 auto_away = gaim_prefs_get_bool("/core/away/away_when_idle"); | 145 auto_away = gaim_prefs_get_bool("/core/away/away_when_idle"); |
| 203 if (auto_away && | 146 if (auto_away && |
| 204 (time_idle > (60 * gaim_prefs_get_int("/core/away/mins_before_away")))) | 147 (time_idle > (60 * gaim_prefs_get_int("/core/away/mins_before_away")))) |
| 205 { | 148 { |
| 206 for (l = gaim_connections_get_all(); l != NULL; l = l->next) | 149 gaim_savedstatus_set_idleaway(TRUE); |
| 207 set_account_autoaway(l->data); | |
| 208 } | 150 } |
| 209 else if (time_idle < 60 * gaim_prefs_get_int("/core/away/mins_before_away")) | 151 else if (time_idle < 60 * gaim_prefs_get_int("/core/away/mins_before_away")) |
| 210 { | 152 { |
| 211 for (l = gaim_connections_get_all(); l != NULL; l = l->next) | 153 gaim_savedstatus_set_idleaway(FALSE); |
| 212 unset_account_autoaway(l->data); | |
| 213 } | 154 } |
| 214 | 155 |
| 215 /* Idle reporting stuff */ | 156 /* Idle reporting stuff */ |
| 216 if (report_idle && (time_idle >= IDLEMARK)) | 157 if (report_idle && (time_idle >= IDLEMARK)) |
| 217 { | 158 { |
| 250 { | 191 { |
| 251 GaimAccount *account; | 192 GaimAccount *account; |
| 252 | 193 |
| 253 account = gaim_connection_get_account(gc); | 194 account = gaim_connection_get_account(gc); |
| 254 set_account_unidle(account); | 195 set_account_unidle(account); |
| 255 unset_account_autoaway(gc); | |
| 256 } | 196 } |
| 257 | 197 |
| 258 void | 198 void |
| 259 gaim_idle_touch() | 199 gaim_idle_touch() |
| 260 { | 200 { |
