Sat, 22 Aug 2020 02:58:07 -0500
Remove the Gtk Ticker plugin as it doesn't scale to today's IM networks
Remove the ticker plugin as it doesn't scale to todays typical IM usage.
Testing Done:
Compile and install.
Reviewed at https://reviews.imfreedom.org/r/81/
| 12272 | 1 | /* |
| 15884 | 2 | * purple |
| 12272 | 3 | * |
| 15884 | 4 | * Purple is the legal property of its developers, whose names are too numerous |
| 12272 | 5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 6 | * source distribution. | |
| 7 | * | |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19569
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 12272 | 21 | * |
| 22 | */ | |
| 23 | ||
| 24 | #include "connection.h" | |
| 25 | #include "debug.h" | |
|
22351
6ca0640b3d31
Change some g_idle_add(...) calls in libpurple to purple_timeout_add(0, ...)
Mark Doliner <markdoliner@pidgin.im>
parents:
22108
diff
changeset
|
26 | #include "eventloop.h" |
| 12272 | 27 | #include "idle.h" |
| 28 | #include "log.h" | |
| 29 | #include "prefs.h" | |
| 30 | #include "savedstatuses.h" | |
| 31 | #include "signals.h" | |
| 32 | ||
| 33 | typedef enum | |
| 34 | { | |
| 15884 | 35 | PURPLE_IDLE_NOT_AWAY = 0, |
| 36 | PURPLE_IDLE_AUTO_AWAY, | |
| 37 | PURPLE_IDLE_AWAY_BUT_NOT_AUTO_AWAY | |
| 12272 | 38 | |
| 15884 | 39 | } PurpleAutoAwayState; |
| 12272 | 40 | |
| 15884 | 41 | static PurpleIdleUiOps *idle_ui_ops = NULL; |
| 12272 | 42 | |
|
35462
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
26891
diff
changeset
|
43 | /* |
| 12272 | 44 | * This is needed for the I'dle Mak'er plugin to work correctly. We |
| 45 | * use it to determine if we're the ones who set our accounts idle | |
| 46 | * or if someone else did it (the I'dle Mak'er plugin, for example). | |
|
12825
0989792c930b
[gaim-migrate @ 15173]
Mark Doliner <markdoliner@pidgin.im>
parents:
12573
diff
changeset
|
47 | * Basically we just keep track of which accounts were set idle by us, |
|
0989792c930b
[gaim-migrate @ 15173]
Mark Doliner <markdoliner@pidgin.im>
parents:
12573
diff
changeset
|
48 | * and then we'll only set these specific accounts unidle when the |
|
0989792c930b
[gaim-migrate @ 15173]
Mark Doliner <markdoliner@pidgin.im>
parents:
12573
diff
changeset
|
49 | * user returns. |
| 12272 | 50 | */ |
|
12825
0989792c930b
[gaim-migrate @ 15173]
Mark Doliner <markdoliner@pidgin.im>
parents:
12573
diff
changeset
|
51 | static GList *idled_accts = NULL; |
| 12272 | 52 | |
| 53 | static guint idle_timer = 0; | |
| 54 | ||
| 55 | static time_t last_active_time = 0; | |
| 56 | ||
| 57 | static void | |
| 15884 | 58 | set_account_idle(PurpleAccount *account, int time_idle) |
| 12272 | 59 | { |
| 15884 | 60 | PurplePresence *presence; |
| 12272 | 61 | |
| 15884 | 62 | presence = purple_account_get_presence(account); |
| 12272 | 63 | |
| 15884 | 64 | if (purple_presence_is_idle(presence)) |
| 12272 | 65 | /* This account is already idle! */ |
| 66 | return; | |
| 67 | ||
| 15884 | 68 | purple_debug_info("idle", "Setting %s idle %d seconds\n", |
| 69 | purple_account_get_username(account), time_idle); | |
| 70 | purple_presence_set_idle(presence, TRUE, time(NULL) - time_idle); | |
|
12825
0989792c930b
[gaim-migrate @ 15173]
Mark Doliner <markdoliner@pidgin.im>
parents:
12573
diff
changeset
|
71 | idled_accts = g_list_prepend(idled_accts, account); |
| 12272 | 72 | } |
| 73 | ||
| 74 | static void | |
| 15884 | 75 | set_account_unidle(PurpleAccount *account) |
| 12272 | 76 | { |
| 15884 | 77 | PurplePresence *presence; |
| 12272 | 78 | |
| 15884 | 79 | presence = purple_account_get_presence(account); |
| 12272 | 80 | |
|
12825
0989792c930b
[gaim-migrate @ 15173]
Mark Doliner <markdoliner@pidgin.im>
parents:
12573
diff
changeset
|
81 | idled_accts = g_list_remove(idled_accts, account); |
|
0989792c930b
[gaim-migrate @ 15173]
Mark Doliner <markdoliner@pidgin.im>
parents:
12573
diff
changeset
|
82 | |
| 15884 | 83 | if (!purple_presence_is_idle(presence)) |
| 12272 | 84 | /* This account is already unidle! */ |
| 85 | return; | |
| 86 | ||
| 15884 | 87 | purple_debug_info("idle", "Setting %s unidle\n", |
| 88 | purple_account_get_username(account)); | |
| 89 | purple_presence_set_idle(presence, FALSE, 0); | |
| 12272 | 90 | } |
| 91 | ||
| 17130 | 92 | |
|
17579
4c3e8468d487
Clean up the idle checking callback slightly.
Daniel Atallah <datallah@pidgin.im>
parents:
17536
diff
changeset
|
93 | static gboolean no_away = FALSE; |
| 17130 | 94 | static gint time_until_next_idle_event; |
| 12272 | 95 | /* |
| 96 | * This function should be called when you think your idle state | |
| 97 | * may have changed. Maybe you're over the 10-minute mark and | |
| 15884 | 98 | * Purple should start reporting idle time to the server. Maybe |
| 12272 | 99 | * you've returned from being idle. Maybe your auto-away message |
| 100 | * should be set. | |
| 101 | * | |
| 102 | * There is no harm to calling this many many times, other than | |
|
17349
c5abad45e8a7
Update a comment: We don't check idle status every 5 seconds any more.
Richard Laager <rlaager@pidgin.im>
parents:
17248
diff
changeset
|
103 | * it will be kinda slow. This is called by a timer set when |
|
c5abad45e8a7
Update a comment: We don't check idle status every 5 seconds any more.
Richard Laager <rlaager@pidgin.im>
parents:
17248
diff
changeset
|
104 | * Purple starts. It is also called when you send an IM, a chat, etc. |
| 12272 | 105 | * |
| 106 | * This function has 3 sections. | |
| 107 | * 1. Get your idle time. It will query XScreenSaver or Windows | |
| 15884 | 108 | * or use the Purple idle time. Whatever. |
| 12272 | 109 | * 2. Set or unset your auto-away message. |
| 110 | * 3. Report your current idle time to the IM server. | |
| 111 | */ | |
| 17130 | 112 | |
| 113 | static void | |
| 114 | check_idleness(void) | |
| 12272 | 115 | { |
|
35382
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
26891
diff
changeset
|
116 | time_t time_idle = 0; |
| 12272 | 117 | gboolean auto_away; |
|
12573
1fc347b54974
[gaim-migrate @ 14895]
Mark Doliner <markdoliner@pidgin.im>
parents:
12412
diff
changeset
|
118 | const gchar *idle_reporting; |
|
17579
4c3e8468d487
Clean up the idle checking callback slightly.
Daniel Atallah <datallah@pidgin.im>
parents:
17536
diff
changeset
|
119 | gboolean report_idle = TRUE; |
| 17130 | 120 | gint away_seconds = 0; |
|
17536
b04036df5ac6
Compiler be quiet! Fixes this compile warning:
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17349
diff
changeset
|
121 | gint idle_recheck_interval = 0; |
|
18949
7ba397b0f34e
Fix idle reporting as discussed on devel@. Poll as needed when we're not idle, and poll frequently (once every three seconds) when we are. Fixes #1357
Sean Egan <seanegan@pidgin.im>
parents:
18191
diff
changeset
|
122 | gint idle_poll_seconds = purple_prefs_get_int("/purple/away/mins_before_away") * 60; |
| 15884 | 123 | purple_signal_emit(purple_blist_get_handle(), "update-idle"); |
| 12272 | 124 | |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
15884
diff
changeset
|
125 | idle_reporting = purple_prefs_get_string("/purple/away/idle_reporting"); |
|
17579
4c3e8468d487
Clean up the idle checking callback slightly.
Daniel Atallah <datallah@pidgin.im>
parents:
17536
diff
changeset
|
126 | auto_away = purple_prefs_get_bool("/purple/away/away_when_idle"); |
|
4c3e8468d487
Clean up the idle checking callback slightly.
Daniel Atallah <datallah@pidgin.im>
parents:
17536
diff
changeset
|
127 | |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
23196
diff
changeset
|
128 | if (purple_strequal(idle_reporting, "system") && |
|
12573
1fc347b54974
[gaim-migrate @ 14895]
Mark Doliner <markdoliner@pidgin.im>
parents:
12412
diff
changeset
|
129 | (idle_ui_ops != NULL) && (idle_ui_ops->get_time_idle != NULL)) |
|
1fc347b54974
[gaim-migrate @ 14895]
Mark Doliner <markdoliner@pidgin.im>
parents:
12412
diff
changeset
|
130 | { |
|
1fc347b54974
[gaim-migrate @ 14895]
Mark Doliner <markdoliner@pidgin.im>
parents:
12412
diff
changeset
|
131 | /* Use system idle time (mouse or keyboard movement, etc.) */ |
| 12272 | 132 | time_idle = idle_ui_ops->get_time_idle(); |
|
18949
7ba397b0f34e
Fix idle reporting as discussed on devel@. Poll as needed when we're not idle, and poll frequently (once every three seconds) when we are. Fixes #1357
Sean Egan <seanegan@pidgin.im>
parents:
18191
diff
changeset
|
133 | idle_recheck_interval = 1; |
|
12573
1fc347b54974
[gaim-migrate @ 14895]
Mark Doliner <markdoliner@pidgin.im>
parents:
12412
diff
changeset
|
134 | } |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
23196
diff
changeset
|
135 | else if (purple_strequal(idle_reporting, "purple")) |
|
12573
1fc347b54974
[gaim-migrate @ 14895]
Mark Doliner <markdoliner@pidgin.im>
parents:
12412
diff
changeset
|
136 | { |
| 15884 | 137 | /* Use 'Purple idle' */ |
| 12272 | 138 | time_idle = time(NULL) - last_active_time; |
|
17162
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
139 | idle_recheck_interval = 0; |
|
12573
1fc347b54974
[gaim-migrate @ 14895]
Mark Doliner <markdoliner@pidgin.im>
parents:
12412
diff
changeset
|
140 | } |
|
1fc347b54974
[gaim-migrate @ 14895]
Mark Doliner <markdoliner@pidgin.im>
parents:
12412
diff
changeset
|
141 | else |
|
1fc347b54974
[gaim-migrate @ 14895]
Mark Doliner <markdoliner@pidgin.im>
parents:
12412
diff
changeset
|
142 | { |
|
1fc347b54974
[gaim-migrate @ 14895]
Mark Doliner <markdoliner@pidgin.im>
parents:
12412
diff
changeset
|
143 | /* Don't report idle time */ |
|
1fc347b54974
[gaim-migrate @ 14895]
Mark Doliner <markdoliner@pidgin.im>
parents:
12412
diff
changeset
|
144 | report_idle = FALSE; |
| 12272 | 145 | |
|
17579
4c3e8468d487
Clean up the idle checking callback slightly.
Daniel Atallah <datallah@pidgin.im>
parents:
17536
diff
changeset
|
146 | /* If we're not reporting idle, we can still do auto-away. |
|
4c3e8468d487
Clean up the idle checking callback slightly.
Daniel Atallah <datallah@pidgin.im>
parents:
17536
diff
changeset
|
147 | * First try "system" and if that isn't possible, use "purple" */ |
|
17162
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
148 | if (auto_away) |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
149 | { |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
150 | if ((idle_ui_ops != NULL) && (idle_ui_ops->get_time_idle != NULL)) |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
151 | { |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
152 | time_idle = idle_ui_ops->get_time_idle(); |
|
18949
7ba397b0f34e
Fix idle reporting as discussed on devel@. Poll as needed when we're not idle, and poll frequently (once every three seconds) when we are. Fixes #1357
Sean Egan <seanegan@pidgin.im>
parents:
18191
diff
changeset
|
153 | idle_recheck_interval = 1; |
|
17162
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
154 | } |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
155 | else |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
156 | { |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
157 | time_idle = time(NULL) - last_active_time; |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
158 | idle_recheck_interval = 0; |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
159 | } |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
160 | } |
|
14999
7b3992f19766
[gaim-migrate @ 17709]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
161 | else |
|
17162
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
162 | { |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
163 | if (!no_away) |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
164 | { |
|
19569
dcc2a321208e
Prevent recursive idle handling loop. Patch from 'Gambit'
Sean Egan <seanegan@pidgin.im>
parents:
18949
diff
changeset
|
165 | no_away = TRUE; |
|
17162
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
166 | purple_savedstatus_set_idleaway(FALSE); |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
167 | } |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
168 | time_until_next_idle_event = 0; |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
169 | return; |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
170 | } |
|
14999
7b3992f19766
[gaim-migrate @ 17709]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
171 | } |
|
7b3992f19766
[gaim-migrate @ 17709]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
172 | |
|
18949
7ba397b0f34e
Fix idle reporting as discussed on devel@. Poll as needed when we're not idle, and poll frequently (once every three seconds) when we are. Fixes #1357
Sean Egan <seanegan@pidgin.im>
parents:
18191
diff
changeset
|
173 | time_until_next_idle_event = idle_poll_seconds - time_idle; |
|
17161
c4e7791b276f
Move the time_until_next_idle_event < 0 check to clarify.
Richard Laager <rlaager@pidgin.im>
parents:
17160
diff
changeset
|
174 | if (time_until_next_idle_event < 0) |
|
c4e7791b276f
Move the time_until_next_idle_event < 0 check to clarify.
Richard Laager <rlaager@pidgin.im>
parents:
17160
diff
changeset
|
175 | { |
|
17162
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
176 | /* If we're already idle, check again as appropriate. */ |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
177 | time_until_next_idle_event = idle_recheck_interval; |
|
17161
c4e7791b276f
Move the time_until_next_idle_event < 0 check to clarify.
Richard Laager <rlaager@pidgin.im>
parents:
17160
diff
changeset
|
178 | } |
| 17130 | 179 | |
| 180 | if (auto_away || !no_away) | |
| 181 | away_seconds = 60 * purple_prefs_get_int("/purple/away/mins_before_away"); | |
| 182 | ||
| 183 | if (auto_away && time_idle > away_seconds) | |
| 12272 | 184 | { |
| 15884 | 185 | purple_savedstatus_set_idleaway(TRUE); |
|
17579
4c3e8468d487
Clean up the idle checking callback slightly.
Daniel Atallah <datallah@pidgin.im>
parents:
17536
diff
changeset
|
186 | no_away = FALSE; |
| 12272 | 187 | } |
|
26891
0570b1cdf470
Adjust some idle handling code to fix "wedging" idle reporting into never
Paul Aurich <darkrain42@pidgin.im>
parents:
25888
diff
changeset
|
188 | else if (purple_savedstatus_is_idleaway() && time_idle < away_seconds) |
| 12272 | 189 | { |
| 15884 | 190 | purple_savedstatus_set_idleaway(FALSE); |
|
17162
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
191 | if (time_until_next_idle_event == 0 || (away_seconds - time_idle) < time_until_next_idle_event) |
| 17130 | 192 | time_until_next_idle_event = away_seconds - time_idle; |
| 12272 | 193 | } |
| 194 | ||
| 195 | /* Idle reporting stuff */ | |
|
18949
7ba397b0f34e
Fix idle reporting as discussed on devel@. Poll as needed when we're not idle, and poll frequently (once every three seconds) when we are. Fixes #1357
Sean Egan <seanegan@pidgin.im>
parents:
18191
diff
changeset
|
196 | if (report_idle && (time_idle >= idle_poll_seconds)) |
| 12272 | 197 | { |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
198 | GList *l; |
| 15884 | 199 | for (l = purple_connections_get_all(); l != NULL; l = l->next) |
|
12825
0989792c930b
[gaim-migrate @ 15173]
Mark Doliner <markdoliner@pidgin.im>
parents:
12573
diff
changeset
|
200 | { |
| 15884 | 201 | PurpleConnection *gc = l->data; |
| 202 | set_account_idle(purple_connection_get_account(gc), time_idle); | |
|
12825
0989792c930b
[gaim-migrate @ 15173]
Mark Doliner <markdoliner@pidgin.im>
parents:
12573
diff
changeset
|
203 | } |
| 12272 | 204 | } |
|
18949
7ba397b0f34e
Fix idle reporting as discussed on devel@. Poll as needed when we're not idle, and poll frequently (once every three seconds) when we are. Fixes #1357
Sean Egan <seanegan@pidgin.im>
parents:
18191
diff
changeset
|
205 | else if (!report_idle || (time_idle < idle_poll_seconds )) |
| 12272 | 206 | { |
|
12825
0989792c930b
[gaim-migrate @ 15173]
Mark Doliner <markdoliner@pidgin.im>
parents:
12573
diff
changeset
|
207 | while (idled_accts != NULL) |
|
0989792c930b
[gaim-migrate @ 15173]
Mark Doliner <markdoliner@pidgin.im>
parents:
12573
diff
changeset
|
208 | set_account_unidle(idled_accts->data); |
| 12272 | 209 | } |
| 17130 | 210 | } |
| 12272 | 211 | |
| 17130 | 212 | |
| 213 | /* | |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
214 | * Check idle and set the timer to fire at the next idle-worth event |
| 17130 | 215 | */ |
|
22108
cb9819851163
Squash some compiler warnings, some from my -Wstrict-prototypes fixing.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
216 | static gboolean |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
217 | check_idleness_timer(void) |
| 17130 | 218 | { |
| 219 | check_idleness(); | |
|
17162
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
220 | if (time_until_next_idle_event == 0) |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
221 | idle_timer = 0; |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
222 | else |
|
18069
a8c10d130374
Raise the timeouts one second so they'll work every time (for certain) with
Richard Laager <rlaager@pidgin.im>
parents:
18068
diff
changeset
|
223 | { |
|
a8c10d130374
Raise the timeouts one second so they'll work every time (for certain) with
Richard Laager <rlaager@pidgin.im>
parents:
18068
diff
changeset
|
224 | /* +1 for the boundary, |
|
a8c10d130374
Raise the timeouts one second so they'll work every time (for certain) with
Richard Laager <rlaager@pidgin.im>
parents:
18068
diff
changeset
|
225 | * +1 more for g_timeout_add_seconds rounding. */ |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
36081
diff
changeset
|
226 | idle_timer = g_timeout_add_seconds(time_until_next_idle_event + 2, (GSourceFunc)check_idleness_timer, NULL); |
|
18069
a8c10d130374
Raise the timeouts one second so they'll work every time (for certain) with
Richard Laager <rlaager@pidgin.im>
parents:
18068
diff
changeset
|
227 | } |
| 17130 | 228 | return FALSE; |
| 12272 | 229 | } |
| 230 | ||
| 231 | static void | |
|
36081
6764e037a308
Switch sent-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35597
diff
changeset
|
232 | im_msg_sent_cb(PurpleAccount *account, PurpleMessage *msg, void *data) |
| 12272 | 233 | { |
| 234 | /* Check our idle time after an IM is sent */ | |
| 235 | check_idleness(); | |
| 236 | } | |
| 237 | ||
|
12825
0989792c930b
[gaim-migrate @ 15173]
Mark Doliner <markdoliner@pidgin.im>
parents:
12573
diff
changeset
|
238 | static void |
| 15884 | 239 | signing_on_cb(PurpleConnection *gc, void *data) |
| 14189 | 240 | { |
| 241 | /* When signing on a new account, check if the account should be idle */ | |
| 242 | check_idleness(); | |
| 243 | } | |
| 244 | ||
| 245 | static void | |
| 15884 | 246 | signing_off_cb(PurpleConnection *gc, void *data) |
|
12825
0989792c930b
[gaim-migrate @ 15173]
Mark Doliner <markdoliner@pidgin.im>
parents:
12573
diff
changeset
|
247 | { |
| 15884 | 248 | PurpleAccount *account; |
|
12825
0989792c930b
[gaim-migrate @ 15173]
Mark Doliner <markdoliner@pidgin.im>
parents:
12573
diff
changeset
|
249 | |
| 15884 | 250 | account = purple_connection_get_account(gc); |
|
23196
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22958
diff
changeset
|
251 | set_account_unidle(account); |
|
12825
0989792c930b
[gaim-migrate @ 15173]
Mark Doliner <markdoliner@pidgin.im>
parents:
12573
diff
changeset
|
252 | } |
|
0989792c930b
[gaim-migrate @ 15173]
Mark Doliner <markdoliner@pidgin.im>
parents:
12573
diff
changeset
|
253 | |
|
17162
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
254 | static void |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
255 | idle_reporting_cb(const char *name, PurplePrefType type, gconstpointer val, gpointer data) |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
256 | { |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
257 | if (idle_timer) |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
36081
diff
changeset
|
258 | g_source_remove(idle_timer); |
|
17162
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
259 | idle_timer = 0; |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
260 | check_idleness_timer(); |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
261 | } |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
262 | |
| 12272 | 263 | void |
| 15884 | 264 | purple_idle_touch() |
| 12272 | 265 | { |
| 266 | time(&last_active_time); | |
|
17162
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
267 | if (!no_away) |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
268 | { |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
269 | if (idle_timer) |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
36081
diff
changeset
|
270 | g_source_remove(idle_timer); |
|
17162
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
271 | idle_timer = 0; |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
272 | check_idleness_timer(); |
|
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
273 | } |
| 12272 | 274 | } |
| 275 | ||
| 276 | void | |
| 15884 | 277 | purple_idle_set(time_t time) |
| 12272 | 278 | { |
| 279 | last_active_time = time; | |
| 280 | } | |
| 281 | ||
| 35572 | 282 | static PurpleIdleUiOps * |
| 283 | purple_idle_ui_ops_copy(PurpleIdleUiOps *ops) | |
| 284 | { | |
| 285 | PurpleIdleUiOps *ops_new; | |
| 286 | ||
| 287 | g_return_val_if_fail(ops != NULL, NULL); | |
| 288 | ||
| 289 | ops_new = g_new(PurpleIdleUiOps, 1); | |
| 290 | *ops_new = *ops; | |
| 291 | ||
| 292 | return ops_new; | |
| 293 | } | |
| 294 | ||
| 295 | GType | |
| 296 | purple_idle_ui_ops_get_type(void) | |
| 297 | { | |
| 298 | static GType type = 0; | |
| 299 | ||
| 300 | if (type == 0) { | |
| 301 | type = g_boxed_type_register_static("PurpleIdleUiOps", | |
| 302 | (GBoxedCopyFunc)purple_idle_ui_ops_copy, | |
|
35597
7fcfcf147b99
Use g_free as UiOps structures GBoxed free function
Ankit Vani <a@nevitus.org>
parents:
35572
diff
changeset
|
303 | (GBoxedFreeFunc)g_free); |
| 35572 | 304 | } |
| 305 | ||
| 306 | return type; | |
| 307 | } | |
| 308 | ||
| 12272 | 309 | void |
| 15884 | 310 | purple_idle_set_ui_ops(PurpleIdleUiOps *ops) |
| 12272 | 311 | { |
| 312 | idle_ui_ops = ops; | |
| 313 | } | |
| 314 | ||
| 15884 | 315 | PurpleIdleUiOps * |
| 316 | purple_idle_get_ui_ops(void) | |
| 12272 | 317 | { |
| 318 | return idle_ui_ops; | |
| 319 | } | |
| 320 | ||
|
12412
8abe3226695e
[gaim-migrate @ 14719]
Richard Laager <rlaager@pidgin.im>
parents:
12272
diff
changeset
|
321 | static void * |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
322 | purple_idle_get_handle(void) |
| 12272 | 323 | { |
| 324 | static int handle; | |
| 325 | ||
| 326 | return &handle; | |
| 327 | } | |
| 328 | ||
|
17741
5075c0d3a19a
I think this will fix the problem that elb had where bonjour (and probably other accounts too) were signing on initially when -n was specified.
Daniel Atallah <datallah@pidgin.im>
parents:
17579
diff
changeset
|
329 | static gboolean _do_purple_idle_touch_cb(gpointer data) |
|
5075c0d3a19a
I think this will fix the problem that elb had where bonjour (and probably other accounts too) were signing on initially when -n was specified.
Daniel Atallah <datallah@pidgin.im>
parents:
17579
diff
changeset
|
330 | { |
|
18949
7ba397b0f34e
Fix idle reporting as discussed on devel@. Poll as needed when we're not idle, and poll frequently (once every three seconds) when we are. Fixes #1357
Sean Egan <seanegan@pidgin.im>
parents:
18191
diff
changeset
|
331 | int idle_poll_minutes = purple_prefs_get_int("/purple/away/mins_before_away"); |
|
7ba397b0f34e
Fix idle reporting as discussed on devel@. Poll as needed when we're not idle, and poll frequently (once every three seconds) when we are. Fixes #1357
Sean Egan <seanegan@pidgin.im>
parents:
18191
diff
changeset
|
332 | |
|
7ba397b0f34e
Fix idle reporting as discussed on devel@. Poll as needed when we're not idle, and poll frequently (once every three seconds) when we are. Fixes #1357
Sean Egan <seanegan@pidgin.im>
parents:
18191
diff
changeset
|
333 | /* +1 more for g_timeout_add_seconds rounding. */ |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
36081
diff
changeset
|
334 | idle_timer = g_timeout_add_seconds((idle_poll_minutes * 60) + 2, (GSourceFunc)check_idleness_timer, NULL); |
|
18949
7ba397b0f34e
Fix idle reporting as discussed on devel@. Poll as needed when we're not idle, and poll frequently (once every three seconds) when we are. Fixes #1357
Sean Egan <seanegan@pidgin.im>
parents:
18191
diff
changeset
|
335 | |
|
17741
5075c0d3a19a
I think this will fix the problem that elb had where bonjour (and probably other accounts too) were signing on initially when -n was specified.
Daniel Atallah <datallah@pidgin.im>
parents:
17579
diff
changeset
|
336 | purple_idle_touch(); |
|
5075c0d3a19a
I think this will fix the problem that elb had where bonjour (and probably other accounts too) were signing on initially when -n was specified.
Daniel Atallah <datallah@pidgin.im>
parents:
17579
diff
changeset
|
337 | |
|
5075c0d3a19a
I think this will fix the problem that elb had where bonjour (and probably other accounts too) were signing on initially when -n was specified.
Daniel Atallah <datallah@pidgin.im>
parents:
17579
diff
changeset
|
338 | return FALSE; |
|
5075c0d3a19a
I think this will fix the problem that elb had where bonjour (and probably other accounts too) were signing on initially when -n was specified.
Daniel Atallah <datallah@pidgin.im>
parents:
17579
diff
changeset
|
339 | } |
|
5075c0d3a19a
I think this will fix the problem that elb had where bonjour (and probably other accounts too) were signing on initially when -n was specified.
Daniel Atallah <datallah@pidgin.im>
parents:
17579
diff
changeset
|
340 | |
|
5075c0d3a19a
I think this will fix the problem that elb had where bonjour (and probably other accounts too) were signing on initially when -n was specified.
Daniel Atallah <datallah@pidgin.im>
parents:
17579
diff
changeset
|
341 | |
| 12272 | 342 | void |
| 15884 | 343 | purple_idle_init() |
| 12272 | 344 | { |
| 15884 | 345 | purple_signal_connect(purple_conversations_get_handle(), "sent-im-msg", |
| 346 | purple_idle_get_handle(), | |
| 347 | PURPLE_CALLBACK(im_msg_sent_cb), NULL); | |
| 348 | purple_signal_connect(purple_connections_get_handle(), "signing-on", | |
| 349 | purple_idle_get_handle(), | |
| 350 | PURPLE_CALLBACK(signing_on_cb), NULL); | |
| 351 | purple_signal_connect(purple_connections_get_handle(), "signing-off", | |
| 352 | purple_idle_get_handle(), | |
| 353 | PURPLE_CALLBACK(signing_off_cb), NULL); | |
| 12272 | 354 | |
|
17162
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
355 | purple_prefs_connect_callback(purple_idle_get_handle(), "/purple/away/idle_reporting", |
|
17163
8c150fc133c3
Add a missing semi-colon so this will compile.
Richard Laager <rlaager@pidgin.im>
parents:
17162
diff
changeset
|
356 | idle_reporting_cb, NULL); |
|
17162
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
357 | |
|
17741
5075c0d3a19a
I think this will fix the problem that elb had where bonjour (and probably other accounts too) were signing on initially when -n was specified.
Daniel Atallah <datallah@pidgin.im>
parents:
17579
diff
changeset
|
358 | /* Initialize the idleness asynchronously so it doesn't check idleness, |
|
5075c0d3a19a
I think this will fix the problem that elb had where bonjour (and probably other accounts too) were signing on initially when -n was specified.
Daniel Atallah <datallah@pidgin.im>
parents:
17579
diff
changeset
|
359 | * and potentially try to change the status before the UI is initialized */ |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
36081
diff
changeset
|
360 | g_timeout_add(0, _do_purple_idle_touch_cb, NULL); |
|
17741
5075c0d3a19a
I think this will fix the problem that elb had where bonjour (and probably other accounts too) were signing on initially when -n was specified.
Daniel Atallah <datallah@pidgin.im>
parents:
17579
diff
changeset
|
361 | |
| 12272 | 362 | } |
| 363 | ||
| 364 | void | |
| 15884 | 365 | purple_idle_uninit() |
| 12272 | 366 | { |
| 15884 | 367 | purple_signals_disconnect_by_handle(purple_idle_get_handle()); |
|
17162
38f0cf5afda1
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@pidgin.im>
parents:
17161
diff
changeset
|
368 | purple_prefs_disconnect_by_handle(purple_idle_get_handle()); |
| 12272 | 369 | |
| 370 | /* Remove the idle timer */ | |
| 371 | if (idle_timer > 0) | |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
36081
diff
changeset
|
372 | g_source_remove(idle_timer); |
| 12272 | 373 | idle_timer = 0; |
| 374 | } |