Mercurial > pidgin.yaz
annotate libpurple/idle.c @ 25501:be1c61b5f30d
propagate from branch 'im.pidgin.pidgin' (head 4b50880d8517570eaa67d4cd9d88c5934bb832f1)
to branch 'im.pidgin.pidgin.yaz' (head eb10df5cf156fff3f6d9f0ad9f8d81e5b8f833b4)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Fri, 08 Jun 2007 03:19:13 +0000 |
parents | ac504f643092 |
children | 81d42bfe31fa 2f9eabdc6011 |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
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 #define IDLEMARK 600 /* 10 minutes! */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 typedef enum |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 { |
15823 | 37 PURPLE_IDLE_NOT_AWAY = 0, |
38 PURPLE_IDLE_AUTO_AWAY, | |
39 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
|
40 |
15823 | 41 } PurpleAutoAwayState; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 |
15823 | 43 static PurpleIdleUiOps *idle_ui_ops = NULL; |
15374
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 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 * 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
|
47 * 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
|
48 * 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
|
49 * 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
|
50 * 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
|
51 * user returns. |
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 GList *idled_accts = NULL; |
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 guint idle_timer = 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 time_t last_active_time = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 static void |
15823 | 60 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
|
61 { |
15823 | 62 PurplePresence *presence; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 |
15823 | 64 presence = purple_account_get_presence(account); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 |
15823 | 66 if (purple_presence_is_idle(presence)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 /* This account is already idle! */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 |
15823 | 70 purple_debug_info("idle", "Setting %s idle %d seconds\n", |
71 purple_account_get_username(account), time_idle); | |
72 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
|
73 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
|
74 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 static void |
15823 | 77 set_account_unidle(PurpleAccount *account) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 { |
15823 | 79 PurplePresence *presence; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 |
15823 | 81 presence = purple_account_get_presence(account); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 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
|
84 |
15823 | 85 if (!purple_presence_is_idle(presence)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 /* This account is already unidle! */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 |
15823 | 89 purple_debug_info("idle", "Setting %s unidle\n", |
90 purple_account_get_username(account)); | |
91 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
|
92 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
94 |
17711
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17668
diff
changeset
|
95 static gboolean no_away = FALSE; |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
96 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
|
97 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 * 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
|
99 * may have changed. Maybe you're over the 10-minute mark and |
15823 | 100 * 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
|
101 * 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
|
102 * should be set. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
103 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
104 * 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
|
105 * 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
|
106 * 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
|
107 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 * This function has 3 sections. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 * 1. Get your idle time. It will query XScreenSaver or Windows |
15823 | 110 * 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
|
111 * 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
|
112 * 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
|
113 */ |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
114 |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
115 static void |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
116 check_idleness(void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 time_t time_idle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
119 gboolean auto_away; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 const gchar *idle_reporting; |
17711
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17668
diff
changeset
|
121 gboolean report_idle = TRUE; |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
122 gint away_seconds = 0; |
17668
010e8f32a0af
Compiler be quiet! Fixes this compile warning:
Stu Tomlinson <stu@nosnilmot.com>
parents:
17314
diff
changeset
|
123 gint idle_recheck_interval = 0; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 |
15823 | 125 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
|
126 |
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
|
127 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
|
128 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
|
129 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 if (!strcmp(idle_reporting, "system") && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 (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
|
132 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
133 /* 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
|
134 time_idle = idle_ui_ops->get_time_idle(); |
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
|
135 idle_recheck_interval = 60; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 } |
15823 | 137 else if (!strcmp(idle_reporting, "purple")) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 { |
15823 | 139 /* Use 'Purple idle' */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
140 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
|
141 idle_recheck_interval = 0; |
15374
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 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
144 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 /* Don't report idle time */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 time_idle = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 report_idle = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
148 |
17711
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17668
diff
changeset
|
149 /* 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
|
150 * 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
|
151 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
|
152 { |
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 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
|
154 { |
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
|
155 time_idle = idle_ui_ops->get_time_idle(); |
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 idle_recheck_interval = 60; |
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 } |
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 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
|
159 { |
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 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
|
161 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
|
162 } |
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
|
163 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 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
|
165 { |
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 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
|
167 { |
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); |
17711
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17668
diff
changeset
|
169 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
|
170 } |
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 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
|
172 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
|
173 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 |
17101
6545d21b6f5b
Move the time_until_next_idle_event < 0 check to clarify.
Richard Laager <rlaager@wiktel.com>
parents:
17100
diff
changeset
|
176 time_until_next_idle_event = IDLEMARK - time_idle; |
6545d21b6f5b
Move the time_until_next_idle_event < 0 check to clarify.
Richard Laager <rlaager@wiktel.com>
parents:
17100
diff
changeset
|
177 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
|
178 { |
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
|
179 /* 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
|
180 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
|
181 } |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
182 |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
183 if (auto_away || !no_away) |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
184 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
|
185 |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
186 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
|
187 { |
15823 | 188 purple_savedstatus_set_idleaway(TRUE); |
17711
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17668
diff
changeset
|
189 no_away = FALSE; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
190 } |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
191 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
|
192 { |
17711
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17668
diff
changeset
|
193 no_away = TRUE; |
15823 | 194 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
|
195 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
|
196 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
|
197 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 /* Idle reporting stuff */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 if (report_idle && (time_idle >= IDLEMARK)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 { |
17711
ac504f643092
Clean up the idle checking callback slightly.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17668
diff
changeset
|
202 GList *l; |
15823 | 203 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
|
204 { |
15823 | 205 PurpleConnection *gc = l->data; |
206 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
|
207 } |
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 else if (!report_idle || (time_idle < IDLEMARK)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 while (idled_accts != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 set_account_unidle(idled_accts->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 } |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
214 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 |
17087
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 /* |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
218 * 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
|
219 */ |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
220 static gint |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
221 check_idleness_timer() |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
222 { |
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
223 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
|
224 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
|
225 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
|
226 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
|
227 idle_timer = purple_timeout_add(1000 * (time_until_next_idle_event + 1), check_idleness_timer, NULL); |
17087
e8c3b6da7f18
Part of a patch from:
Richard Laager <rlaager@wiktel.com>
parents:
16427
diff
changeset
|
228 return FALSE; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
229 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 static void |
15823 | 232 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
|
233 const char *message, void *data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
234 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
235 /* 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
|
236 check_idleness(); |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 static void |
15823 | 240 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
|
241 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 /* 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
|
243 check_idleness(); |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
246 static void |
15823 | 247 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
|
248 { |
15823 | 249 PurpleAccount *account; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 |
15823 | 251 account = purple_connection_get_account(gc); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 set_account_unidle(account); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
254 |
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
|
255 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
|
256 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
|
257 { |
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 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
|
259 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
|
260 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
|
261 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
|
262 } |
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 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 void |
15823 | 265 purple_idle_touch() |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 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
|
268 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
|
269 { |
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
|
270 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
|
271 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
|
272 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
|
273 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
|
274 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
275 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
277 void |
15823 | 278 purple_idle_set(time_t time) |
15374
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 last_active_time = time; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 void |
15823 | 284 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
|
285 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
286 idle_ui_ops = ops; |
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 |
15823 | 289 PurpleIdleUiOps * |
290 purple_idle_get_ui_ops(void) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
291 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
292 return idle_ui_ops; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 static void * |
15823 | 296 purple_idle_get_handle() |
15374
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 int handle; |
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 return &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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
303 void |
15823 | 304 purple_idle_init() |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
305 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
306 /* Add the timer to check if we're idle */ |
17089
dfcca72d8653
Run the first timer at IDLEMARK + 1, to ensure we don't hit it right on IDLEMARK.
Richard Laager <rlaager@wiktel.com>
parents:
17088
diff
changeset
|
307 idle_timer = purple_timeout_add(1000 * (IDLEMARK + 1), check_idleness_timer, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
308 |
15823 | 309 purple_signal_connect(purple_conversations_get_handle(), "sent-im-msg", |
310 purple_idle_get_handle(), | |
311 PURPLE_CALLBACK(im_msg_sent_cb), NULL); | |
312 purple_signal_connect(purple_connections_get_handle(), "signing-on", | |
313 purple_idle_get_handle(), | |
314 PURPLE_CALLBACK(signing_on_cb), NULL); | |
315 purple_signal_connect(purple_connections_get_handle(), "signing-off", | |
316 purple_idle_get_handle(), | |
317 PURPLE_CALLBACK(signing_off_cb), NULL); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
318 |
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
|
319 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
|
320 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
|
321 |
15823 | 322 purple_idle_touch(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
323 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
324 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
325 void |
15823 | 326 purple_idle_uninit() |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
327 { |
15823 | 328 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
|
329 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
|
330 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
331 /* Remove the idle timer */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
332 if (idle_timer > 0) |
15823 | 333 purple_timeout_remove(idle_timer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
334 idle_timer = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
335 } |