Mercurial > pidgin
annotate libpurple/idle.c @ 21641:ee7638c696f1
My previous commit caused the scrollbook's children to be tracked correctly - it turns out that this causes problems because they really aren't the children of the scrollbook, they're the notebook'children. This stuff needs to be revisited.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Mon, 26 Nov 2007 06:30:57 +0000 |
parents | 44b4e8bd759b |
children | c38d72677c8a |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
15822 | 2 * purple |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
15822 | 4 * Purple is the legal property of its developers, whose names are too numerous |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
6 * source distribution. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19389
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 #include "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 #include "connection.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 #include "idle.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 #include "log.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #include "prefs.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #include "savedstatuses.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include "signals.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 typedef enum |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 { |
15822 | 35 PURPLE_IDLE_NOT_AWAY = 0, |
36 PURPLE_IDLE_AUTO_AWAY, | |
37 PURPLE_IDLE_AWAY_BUT_NOT_AUTO_AWAY | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 |
15822 | 39 } PurpleAutoAwayState; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 |
15822 | 41 static PurpleIdleUiOps *idle_ui_ops = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 * This is needed for the I'dle Mak'er plugin to work correctly. We |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 * use it to determine if we're the ones who set our accounts idle |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 * or if someone else did it (the I'dle Mak'er plugin, for example). |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 * Basically we just keep track of which accounts were set idle by us, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 * and then we'll only set these specific accounts unidle when the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 * user returns. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 static GList *idled_accts = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 static guint idle_timer = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 static time_t last_active_time = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 static void |
15822 | 58 set_account_idle(PurpleAccount *account, int time_idle) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 { |
15822 | 60 PurplePresence *presence; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 |
15822 | 62 presence = purple_account_get_presence(account); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 |
15822 | 64 if (purple_presence_is_idle(presence)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 /* This account is already idle! */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 |
15822 | 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); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 idled_accts = g_list_prepend(idled_accts, account); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 static void |
15822 | 75 set_account_unidle(PurpleAccount *account) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 { |
15822 | 77 PurplePresence *presence; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 |
15822 | 79 presence = purple_account_get_presence(account); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 idled_accts = g_list_remove(idled_accts, account); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 |
15822 | 83 if (!purple_presence_is_idle(presence)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 /* This account is already unidle! */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 |
15822 | 87 purple_debug_info("idle", "Setting %s unidle\n", |
88 purple_account_get_username(account)); | |
89 purple_presence_set_idle(presence, FALSE, 0); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 |
17074
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
92 |
17486
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17445
diff
changeset
|
93 static gboolean no_away = FALSE; |
17074
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
94 static gint time_until_next_idle_event; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
96 * This function should be called when you think your idle state |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 * may have changed. Maybe you're over the 10-minute mark and |
15822 | 98 * Purple should start reporting idle time to the server. Maybe |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 * you've returned from being idle. Maybe your auto-away message |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 * should be set. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
101 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 * There is no harm to calling this many many times, other than |
17257
42c2d75b3d3e
Update a comment: We don't check idle status every 5 seconds any more.
Richard Laager <rlaager@wiktel.com>
parents:
17153
diff
changeset
|
103 * it will be kinda slow. This is called by a timer set when |
42c2d75b3d3e
Update a comment: We don't check idle status every 5 seconds any more.
Richard Laager <rlaager@wiktel.com>
parents:
17153
diff
changeset
|
104 * Purple starts. It is also called when you send an IM, a chat, etc. |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 * This function has 3 sections. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 * 1. Get your idle time. It will query XScreenSaver or Windows |
15822 | 108 * or use the Purple idle time. Whatever. |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 * 2. Set or unset your auto-away message. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
110 * 3. Report your current idle time to the IM server. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 */ |
17074
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
112 |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
113 static void |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
114 check_idleness(void) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
115 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 time_t time_idle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 gboolean auto_away; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 const gchar *idle_reporting; |
17486
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17445
diff
changeset
|
119 gboolean report_idle = TRUE; |
17074
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
120 gint away_seconds = 0; |
17445
010e8f32a0af
Compiler be quiet! Fixes this compile warning:
Stu Tomlinson <stu@nosnilmot.com>
parents:
17257
diff
changeset
|
121 gint idle_recheck_interval = 0; |
18648
667c209521db
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@gmail.com>
parents:
18119
diff
changeset
|
122 gint idle_poll_seconds = purple_prefs_get_int("/purple/away/mins_before_away") * 60; |
15822 | 123 purple_signal_emit(purple_blist_get_handle(), "update-idle"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
15822
diff
changeset
|
125 idle_reporting = purple_prefs_get_string("/purple/away/idle_reporting"); |
17486
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17445
diff
changeset
|
126 auto_away = purple_prefs_get_bool("/purple/away/away_when_idle"); |
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17445
diff
changeset
|
127 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 if (!strcmp(idle_reporting, "system") && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 (idle_ui_ops != NULL) && (idle_ui_ops->get_time_idle != NULL)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 /* Use system idle time (mouse or keyboard movement, etc.) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 time_idle = idle_ui_ops->get_time_idle(); |
18648
667c209521db
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@gmail.com>
parents:
18119
diff
changeset
|
133 idle_recheck_interval = 1; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
134 } |
15822 | 135 else if (!strcmp(idle_reporting, "purple")) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 { |
15822 | 137 /* Use 'Purple idle' */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 time_idle = time(NULL) - last_active_time; |
17089
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
139 idle_recheck_interval = 0; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
140 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
143 /* Don't report idle time */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
144 time_idle = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 report_idle = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 |
17486
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17445
diff
changeset
|
147 /* If we're not reporting idle, we can still do auto-away. |
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17445
diff
changeset
|
148 * First try "system" and if that isn't possible, use "purple" */ |
17089
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
149 if (auto_away) |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
150 { |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
151 if ((idle_ui_ops != NULL) && (idle_ui_ops->get_time_idle != NULL)) |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
152 { |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
153 time_idle = idle_ui_ops->get_time_idle(); |
18648
667c209521db
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@gmail.com>
parents:
18119
diff
changeset
|
154 idle_recheck_interval = 1; |
17089
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
155 } |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
156 else |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
157 { |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
158 time_idle = time(NULL) - last_active_time; |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
159 idle_recheck_interval = 0; |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
160 } |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
161 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
162 else |
17089
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
163 { |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
164 if (!no_away) |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
165 { |
19389
994d36743cbb
Prevent recursive idle handling loop. Patch from 'Gambit'
Sean Egan <seanegan@gmail.com>
parents:
18648
diff
changeset
|
166 no_away = TRUE; |
17089
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
167 purple_savedstatus_set_idleaway(FALSE); |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
168 } |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
169 time_until_next_idle_event = 0; |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
170 return; |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
171 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 |
18648
667c209521db
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@gmail.com>
parents:
18119
diff
changeset
|
174 time_until_next_idle_event = idle_poll_seconds - time_idle; |
17088
6545d21b6f5b
Move the time_until_next_idle_event < 0 check to clarify.
Richard Laager <rlaager@wiktel.com>
parents:
17087
diff
changeset
|
175 if (time_until_next_idle_event < 0) |
6545d21b6f5b
Move the time_until_next_idle_event < 0 check to clarify.
Richard Laager <rlaager@wiktel.com>
parents:
17087
diff
changeset
|
176 { |
17089
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
177 /* If we're already idle, check again as appropriate. */ |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
178 time_until_next_idle_event = idle_recheck_interval; |
17088
6545d21b6f5b
Move the time_until_next_idle_event < 0 check to clarify.
Richard Laager <rlaager@wiktel.com>
parents:
17087
diff
changeset
|
179 } |
17074
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
180 |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
181 if (auto_away || !no_away) |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
182 away_seconds = 60 * purple_prefs_get_int("/purple/away/mins_before_away"); |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
183 |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
184 if (auto_away && time_idle > away_seconds) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
185 { |
15822 | 186 purple_savedstatus_set_idleaway(TRUE); |
17486
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17445
diff
changeset
|
187 no_away = FALSE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
188 } |
17074
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
189 else if (!no_away && time_idle < away_seconds) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
190 { |
17486
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17445
diff
changeset
|
191 no_away = TRUE; |
15822 | 192 purple_savedstatus_set_idleaway(FALSE); |
17089
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
193 if (time_until_next_idle_event == 0 || (away_seconds - time_idle) < time_until_next_idle_event) |
17074
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
194 time_until_next_idle_event = away_seconds - time_idle; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
196 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 /* Idle reporting stuff */ |
18648
667c209521db
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@gmail.com>
parents:
18119
diff
changeset
|
198 if (report_idle && (time_idle >= idle_poll_seconds)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 { |
18063
926ccb104da0
disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents:
18058
diff
changeset
|
200 GList *l; |
15822 | 201 for (l = purple_connections_get_all(); l != NULL; l = l->next) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 { |
15822 | 203 PurpleConnection *gc = l->data; |
204 set_account_idle(purple_connection_get_account(gc), time_idle); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
205 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 } |
18648
667c209521db
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@gmail.com>
parents:
18119
diff
changeset
|
207 else if (!report_idle || (time_idle < idle_poll_seconds )) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
208 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
209 while (idled_accts != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 set_account_unidle(idled_accts->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 } |
17074
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
212 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 |
17074
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
214 |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
215 /* |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
216 * Check idle and set the timer to fire at the next idle-worth event |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
217 */ |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
218 static gint |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
219 check_idleness_timer() |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
220 { |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
221 check_idleness(); |
17089
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
222 if (time_until_next_idle_event == 0) |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
223 idle_timer = 0; |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
224 else |
18007
a8b4444f2515
Raise the timeouts one second so they'll work every time (for certain) with
Richard Laager <rlaager@wiktel.com>
parents:
18006
diff
changeset
|
225 { |
a8b4444f2515
Raise the timeouts one second so they'll work every time (for certain) with
Richard Laager <rlaager@wiktel.com>
parents:
18006
diff
changeset
|
226 /* +1 for the boundary, |
a8b4444f2515
Raise the timeouts one second so they'll work every time (for certain) with
Richard Laager <rlaager@wiktel.com>
parents:
18006
diff
changeset
|
227 * +1 more for g_timeout_add_seconds rounding. */ |
a8b4444f2515
Raise the timeouts one second so they'll work every time (for certain) with
Richard Laager <rlaager@wiktel.com>
parents:
18006
diff
changeset
|
228 idle_timer = purple_timeout_add_seconds(time_until_next_idle_event + 2, check_idleness_timer, NULL); |
a8b4444f2515
Raise the timeouts one second so they'll work every time (for certain) with
Richard Laager <rlaager@wiktel.com>
parents:
18006
diff
changeset
|
229 } |
17074
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16424
diff
changeset
|
230 return FALSE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
232 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
233 static void |
15822 | 234 im_msg_sent_cb(PurpleAccount *account, const char *receiver, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
235 const char *message, void *data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
236 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 /* Check our idle time after an IM is sent */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 check_idleness(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 static void |
15822 | 242 signing_on_cb(PurpleConnection *gc, void *data) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
243 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 /* When signing on a new account, check if the account should be idle */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 check_idleness(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
246 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 static void |
15822 | 249 signing_off_cb(PurpleConnection *gc, void *data) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 { |
15822 | 251 PurpleAccount *account; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 |
15822 | 253 account = purple_connection_get_account(gc); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
254 set_account_unidle(account); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
255 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
256 |
17089
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
257 static void |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
258 idle_reporting_cb(const char *name, PurplePrefType type, gconstpointer val, gpointer data) |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
259 { |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
260 if (idle_timer) |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
261 purple_timeout_remove(idle_timer); |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
262 idle_timer = 0; |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
263 check_idleness_timer(); |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
264 } |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
265 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 void |
15822 | 267 purple_idle_touch() |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 time(&last_active_time); |
17089
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
270 if (!no_away) |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
271 { |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
272 if (idle_timer) |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
273 purple_timeout_remove(idle_timer); |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
274 idle_timer = 0; |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
275 check_idleness_timer(); |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
276 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
277 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
279 void |
15822 | 280 purple_idle_set(time_t time) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
282 last_active_time = time; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
284 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
285 void |
15822 | 286 purple_idle_set_ui_ops(PurpleIdleUiOps *ops) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
287 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
288 idle_ui_ops = ops; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
289 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
290 |
15822 | 291 PurpleIdleUiOps * |
292 purple_idle_get_ui_ops(void) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
293 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
294 return idle_ui_ops; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
296 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
297 static void * |
15822 | 298 purple_idle_get_handle() |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
299 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
300 static int handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
301 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
302 return &handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
303 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
304 |
17633
81d42bfe31fa
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 <daniel.atallah@gmail.com>
parents:
17486
diff
changeset
|
305 static gboolean _do_purple_idle_touch_cb(gpointer data) |
81d42bfe31fa
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 <daniel.atallah@gmail.com>
parents:
17486
diff
changeset
|
306 { |
18648
667c209521db
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@gmail.com>
parents:
18119
diff
changeset
|
307 int idle_poll_minutes = purple_prefs_get_int("/purple/away/mins_before_away"); |
667c209521db
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@gmail.com>
parents:
18119
diff
changeset
|
308 |
667c209521db
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@gmail.com>
parents:
18119
diff
changeset
|
309 /* +1 more for g_timeout_add_seconds rounding. */ |
667c209521db
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@gmail.com>
parents:
18119
diff
changeset
|
310 idle_timer = purple_timeout_add_seconds((idle_poll_minutes * 60) + 2, check_idleness_timer, NULL); |
667c209521db
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@gmail.com>
parents:
18119
diff
changeset
|
311 |
17633
81d42bfe31fa
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 <daniel.atallah@gmail.com>
parents:
17486
diff
changeset
|
312 purple_idle_touch(); |
81d42bfe31fa
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 <daniel.atallah@gmail.com>
parents:
17486
diff
changeset
|
313 |
81d42bfe31fa
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 <daniel.atallah@gmail.com>
parents:
17486
diff
changeset
|
314 return FALSE; |
81d42bfe31fa
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 <daniel.atallah@gmail.com>
parents:
17486
diff
changeset
|
315 } |
81d42bfe31fa
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 <daniel.atallah@gmail.com>
parents:
17486
diff
changeset
|
316 |
81d42bfe31fa
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 <daniel.atallah@gmail.com>
parents:
17486
diff
changeset
|
317 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
318 void |
15822 | 319 purple_idle_init() |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
320 { |
15822 | 321 purple_signal_connect(purple_conversations_get_handle(), "sent-im-msg", |
322 purple_idle_get_handle(), | |
323 PURPLE_CALLBACK(im_msg_sent_cb), NULL); | |
324 purple_signal_connect(purple_connections_get_handle(), "signing-on", | |
325 purple_idle_get_handle(), | |
326 PURPLE_CALLBACK(signing_on_cb), NULL); | |
327 purple_signal_connect(purple_connections_get_handle(), "signing-off", | |
328 purple_idle_get_handle(), | |
329 PURPLE_CALLBACK(signing_off_cb), NULL); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
330 |
17089
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
331 purple_prefs_connect_callback(purple_idle_get_handle(), "/purple/away/idle_reporting", |
17090
bf27ef68e81a
Add a missing semi-colon so this will compile.
Richard Laager <rlaager@wiktel.com>
parents:
17089
diff
changeset
|
332 idle_reporting_cb, NULL); |
17089
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
333 |
17633
81d42bfe31fa
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 <daniel.atallah@gmail.com>
parents:
17486
diff
changeset
|
334 /* Initialize the idleness asynchronously so it doesn't check idleness, |
81d42bfe31fa
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 <daniel.atallah@gmail.com>
parents:
17486
diff
changeset
|
335 * and potentially try to change the status before the UI is initialized */ |
81d42bfe31fa
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 <daniel.atallah@gmail.com>
parents:
17486
diff
changeset
|
336 g_idle_add(_do_purple_idle_touch_cb, NULL); |
81d42bfe31fa
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 <daniel.atallah@gmail.com>
parents:
17486
diff
changeset
|
337 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
338 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
339 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
340 void |
15822 | 341 purple_idle_uninit() |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
342 { |
15822 | 343 purple_signals_disconnect_by_handle(purple_idle_get_handle()); |
17089
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
344 purple_prefs_disconnect_by_handle(purple_idle_get_handle()); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
345 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 /* Remove the idle timer */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 if (idle_timer > 0) |
15822 | 348 purple_timeout_remove(idle_timer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
349 idle_timer = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 } |