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