Mercurial > pidgin.yaz
annotate libpurple/idle.c @ 24623:35d0ce5f319a
Further cleanup to fix CID 373.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Wed, 10 Dec 2008 02:44:03 +0000 |
parents | d74ff4f23171 |
children | a6e3cb32cdd2 |
rev | line source |
---|---|
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
15823 | 2 * purple |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
15823 | 4 * Purple is the legal property of its developers, whose names are too numerous |
15374
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 |
19680
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 |
15374
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" |
22224
d1b36a8c920a
Change some g_idle_add(...) calls in libpurple to purple_timeout_add(0, ...)
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
27 #include "eventloop.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 #include "idle.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #include "log.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #include "prefs.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include "savedstatuses.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include "signals.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 typedef enum |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 { |
15823 | 36 PURPLE_IDLE_NOT_AWAY = 0, |
37 PURPLE_IDLE_AUTO_AWAY, | |
38 PURPLE_IDLE_AWAY_BUT_NOT_AUTO_AWAY | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 |
15823 | 40 } PurpleAutoAwayState; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 |
15823 | 42 static PurpleIdleUiOps *idle_ui_ops = NULL; |
15374
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 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 * 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
|
46 * 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
|
47 * 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
|
48 * 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
|
49 * 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
|
50 * user returns. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 static GList *idled_accts = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 static guint idle_timer = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 static time_t last_active_time = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 static void |
15823 | 59 set_account_idle(PurpleAccount *account, int time_idle) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 { |
15823 | 61 PurplePresence *presence; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 |
15823 | 63 presence = purple_account_get_presence(account); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 |
15823 | 65 if (purple_presence_is_idle(presence)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 /* This account is already idle! */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 |
15823 | 69 purple_debug_info("idle", "Setting %s idle %d seconds\n", |
70 purple_account_get_username(account), time_idle); | |
71 purple_presence_set_idle(presence, TRUE, time(NULL) - time_idle); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 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
|
73 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 static void |
15823 | 76 set_account_unidle(PurpleAccount *account) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
77 { |
15823 | 78 PurplePresence *presence; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
79 |
15823 | 80 presence = purple_account_get_presence(account); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 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
|
83 |
15823 | 84 if (!purple_presence_is_idle(presence)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 /* This account is already unidle! */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 |
15823 | 88 purple_debug_info("idle", "Setting %s unidle\n", |
89 purple_account_get_username(account)); | |
90 purple_presence_set_idle(presence, FALSE, 0); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
93 |
17711
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17668
diff
changeset
|
94 static gboolean no_away = FALSE; |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
95 static gint time_until_next_idle_event; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
96 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 * 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
|
98 * may have changed. Maybe you're over the 10-minute mark and |
15823 | 99 * Purple should start reporting idle time to the server. Maybe |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 * 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
|
101 * should be set. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
103 * There is no harm to calling this many many times, other than |
17314
42c2d75b3d3e
Update a comment: We don't check idle status every 5 seconds any more.
Richard Laager <rlaager@wiktel.com>
parents:
17186
diff
changeset
|
104 * 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:
17186
diff
changeset
|
105 * Purple starts. It is also called when you send an IM, a chat, etc. |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 * This function has 3 sections. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 * 1. Get your idle time. It will query XScreenSaver or Windows |
15823 | 109 * or use the Purple idle time. Whatever. |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
110 * 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
|
111 * 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
|
112 */ |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
113 |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
114 static void |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
115 check_idleness(void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 time_t time_idle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 gboolean auto_away; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
119 const gchar *idle_reporting; |
17711
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17668
diff
changeset
|
120 gboolean report_idle = TRUE; |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
121 gint away_seconds = 0; |
17668
010e8f32a0af
Compiler be quiet! Fixes this compile warning:
Stu Tomlinson <stu@nosnilmot.com>
parents:
17314
diff
changeset
|
122 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
|
123 gint idle_poll_seconds = purple_prefs_get_int("/purple/away/mins_before_away") * 60; |
15823 | 124 purple_signal_emit(purple_blist_get_handle(), "update-idle"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
15823
diff
changeset
|
126 idle_reporting = purple_prefs_get_string("/purple/away/idle_reporting"); |
17711
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17668
diff
changeset
|
127 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:
17668
diff
changeset
|
128 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 if (!strcmp(idle_reporting, "system") && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 (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
|
131 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 /* 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
|
133 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
|
134 idle_recheck_interval = 1; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
135 } |
15823 | 136 else if (!strcmp(idle_reporting, "purple")) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 { |
15823 | 138 /* Use 'Purple idle' */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 time_idle = time(NULL) - last_active_time; |
17102
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
140 idle_recheck_interval = 0; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
143 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
144 /* Don't report idle time */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 time_idle = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 report_idle = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 |
17711
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17668
diff
changeset
|
148 /* 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:
17668
diff
changeset
|
149 * First try "system" and if that isn't possible, use "purple" */ |
17102
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
150 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:
17101
diff
changeset
|
151 { |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
152 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:
17101
diff
changeset
|
153 { |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
154 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
|
155 idle_recheck_interval = 1; |
17102
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
156 } |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
157 else |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
158 { |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
159 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:
17101
diff
changeset
|
160 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:
17101
diff
changeset
|
161 } |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
162 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
163 else |
17102
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
164 { |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
165 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:
17101
diff
changeset
|
166 { |
19389
994d36743cbb
Prevent recursive idle handling loop. Patch from 'Gambit'
Sean Egan <seanegan@gmail.com>
parents:
18648
diff
changeset
|
167 no_away = TRUE; |
17102
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
168 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:
17101
diff
changeset
|
169 } |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
170 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:
17101
diff
changeset
|
171 return; |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
172 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 |
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
|
175 time_until_next_idle_event = idle_poll_seconds - time_idle; |
17101
6545d21b6f5b
Move the time_until_next_idle_event < 0 check to clarify.
Richard Laager <rlaager@wiktel.com>
parents:
17100
diff
changeset
|
176 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:
17100
diff
changeset
|
177 { |
17102
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
178 /* 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:
17101
diff
changeset
|
179 time_until_next_idle_event = idle_recheck_interval; |
17101
6545d21b6f5b
Move the time_until_next_idle_event < 0 check to clarify.
Richard Laager <rlaager@wiktel.com>
parents:
17100
diff
changeset
|
180 } |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
181 |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
182 if (auto_away || !no_away) |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
183 away_seconds = 60 * purple_prefs_get_int("/purple/away/mins_before_away"); |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
184 |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
185 if (auto_away && time_idle > away_seconds) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
186 { |
15823 | 187 purple_savedstatus_set_idleaway(TRUE); |
17711
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17668
diff
changeset
|
188 no_away = FALSE; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
189 } |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
190 else if (!no_away && time_idle < away_seconds) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
191 { |
17711
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17668
diff
changeset
|
192 no_away = TRUE; |
15823 | 193 purple_savedstatus_set_idleaway(FALSE); |
17102
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
194 if (time_until_next_idle_event == 0 || (away_seconds - time_idle) < time_until_next_idle_event) |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
195 time_until_next_idle_event = away_seconds - time_idle; |
15374
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 /* 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
|
199 if (report_idle && (time_idle >= idle_poll_seconds)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 { |
18063
926ccb104da0
disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents:
18058
diff
changeset
|
201 GList *l; |
15823 | 202 for (l = purple_connections_get_all(); l != NULL; l = l->next) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
203 { |
15823 | 204 PurpleConnection *gc = l->data; |
205 set_account_idle(purple_connection_get_account(gc), time_idle); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
207 } |
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
|
208 else if (!report_idle || (time_idle < idle_poll_seconds )) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
209 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 while (idled_accts != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 set_account_unidle(idled_accts->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 } |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
213 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
215 |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
216 /* |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
217 * 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:
16427
diff
changeset
|
218 */ |
22011
76e0463db3aa
Squash some compiler warnings, some from my -Wstrict-prototypes fixing.
Richard Laager <rlaager@wiktel.com>
parents:
22007
diff
changeset
|
219 static gboolean |
22007
c38d72677c8a
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
220 check_idleness_timer(void) |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
221 { |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
222 check_idleness(); |
17102
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
223 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:
17101
diff
changeset
|
224 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:
17101
diff
changeset
|
225 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
|
226 { |
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 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
|
228 * +1 more for g_timeout_add_seconds rounding. */ |
22011
76e0463db3aa
Squash some compiler warnings, some from my -Wstrict-prototypes fixing.
Richard Laager <rlaager@wiktel.com>
parents:
22007
diff
changeset
|
229 idle_timer = purple_timeout_add_seconds(time_until_next_idle_event + 2, (GSourceFunc)check_idleness_timer, NULL); |
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
|
230 } |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
231 return FALSE; |
15374
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
234 static void |
15823 | 235 im_msg_sent_cb(PurpleAccount *account, const char *receiver, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
236 const char *message, void *data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 /* 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
|
239 check_idleness(); |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 static void |
15823 | 243 signing_on_cb(PurpleConnection *gc, void *data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 /* 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
|
246 check_idleness(); |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
249 static void |
15823 | 250 signing_off_cb(PurpleConnection *gc, void *data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 { |
15823 | 252 PurpleAccount *account; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 |
15823 | 254 account = purple_connection_get_account(gc); |
23056
d74ff4f23171
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <stu@nosnilmot.com>
parents:
22787
diff
changeset
|
255 set_account_unidle(account); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
256 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 |
17102
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
258 static void |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
259 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:
17101
diff
changeset
|
260 { |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
261 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:
17101
diff
changeset
|
262 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:
17101
diff
changeset
|
263 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:
17101
diff
changeset
|
264 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:
17101
diff
changeset
|
265 } |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
266 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 void |
15823 | 268 purple_idle_touch() |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 time(&last_active_time); |
17102
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
271 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:
17101
diff
changeset
|
272 { |
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
273 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:
17101
diff
changeset
|
274 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:
17101
diff
changeset
|
275 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:
17101
diff
changeset
|
276 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:
17101
diff
changeset
|
277 } |
15374
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 void |
15823 | 281 purple_idle_set(time_t time) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
282 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 last_active_time = time; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
286 void |
15823 | 287 purple_idle_set_ui_ops(PurpleIdleUiOps *ops) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
288 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
289 idle_ui_ops = ops; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
290 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
291 |
15823 | 292 PurpleIdleUiOps * |
293 purple_idle_get_ui_ops(void) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
294 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 return idle_ui_ops; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
298 static void * |
22007
c38d72677c8a
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
299 purple_idle_get_handle(void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
300 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
301 static int handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
302 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
303 return &handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
304 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
305 |
17872
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:
17711
diff
changeset
|
306 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:
17711
diff
changeset
|
307 { |
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
|
308 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
|
309 |
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 /* +1 more for g_timeout_add_seconds rounding. */ |
22011
76e0463db3aa
Squash some compiler warnings, some from my -Wstrict-prototypes fixing.
Richard Laager <rlaager@wiktel.com>
parents:
22007
diff
changeset
|
311 idle_timer = purple_timeout_add_seconds((idle_poll_minutes * 60) + 2, (GSourceFunc)check_idleness_timer, NULL); |
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
|
312 |
17872
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:
17711
diff
changeset
|
313 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:
17711
diff
changeset
|
314 |
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:
17711
diff
changeset
|
315 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:
17711
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:
17711
diff
changeset
|
317 |
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:
17711
diff
changeset
|
318 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
319 void |
15823 | 320 purple_idle_init() |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
321 { |
15823 | 322 purple_signal_connect(purple_conversations_get_handle(), "sent-im-msg", |
323 purple_idle_get_handle(), | |
324 PURPLE_CALLBACK(im_msg_sent_cb), NULL); | |
325 purple_signal_connect(purple_connections_get_handle(), "signing-on", | |
326 purple_idle_get_handle(), | |
327 PURPLE_CALLBACK(signing_on_cb), NULL); | |
328 purple_signal_connect(purple_connections_get_handle(), "signing-off", | |
329 purple_idle_get_handle(), | |
330 PURPLE_CALLBACK(signing_off_cb), NULL); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
331 |
17102
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
332 purple_prefs_connect_callback(purple_idle_get_handle(), "/purple/away/idle_reporting", |
17103
bf27ef68e81a
Add a missing semi-colon so this will compile.
Richard Laager <rlaager@wiktel.com>
parents:
17102
diff
changeset
|
333 idle_reporting_cb, NULL); |
17102
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
334 |
17872
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:
17711
diff
changeset
|
335 /* 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:
17711
diff
changeset
|
336 * and potentially try to change the status before the UI is initialized */ |
22224
d1b36a8c920a
Change some g_idle_add(...) calls in libpurple to purple_timeout_add(0, ...)
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
337 purple_timeout_add(0, _do_purple_idle_touch_cb, NULL); |
17872
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:
17711
diff
changeset
|
338 |
15374
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
341 void |
15823 | 342 purple_idle_uninit() |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 { |
15823 | 344 purple_signals_disconnect_by_handle(purple_idle_get_handle()); |
17102
e7e033a38612
When using Purple idle, don't run a timer at all when idleaway. When using
Richard Laager <rlaager@wiktel.com>
parents:
17101
diff
changeset
|
345 purple_prefs_disconnect_by_handle(purple_idle_get_handle()); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 /* Remove the idle timer */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
348 if (idle_timer > 0) |
15823 | 349 purple_timeout_remove(idle_timer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 idle_timer = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
351 } |