Mon, 09 Jun 2008 19:31:43 +0000
Do not disable default smileys with dupliate shortcuts if custom smileys
are not supported by the prpl. Also, show the text of the disabled smiley
in the tooltip.
And use _prepend and _reverse, instead of _append for GLists, since some
people apparently have hundreds of custom smileys.
Closes #6057.
committer: Sadrul Habib Chowdhury <sadrul@pidgin.im>
| 5717 | 1 | /* |
|
10297
b36800725b7a
[gaim-migrate @ 11480]
Evan Schoenberg <evands@pidgin.im>
parents:
10211
diff
changeset
|
2 | * @file gtkconn.c GTK+ Connection API |
|
16254
eeb2bba4dc94
Rename the Doxygen group from gtkui to pidgin.
Richard Laager <rlaager@pidgin.im>
parents:
16071
diff
changeset
|
3 | * @ingroup pidgin |
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
4 | */ |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
5 | |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
6 | /* pidgin |
| 5717 | 7 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
8 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 8046 | 9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 10 | * source distribution. | |
| 5717 | 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify | |
| 13 | * it under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation; either version 2 of the License, or | |
| 15 | * (at your option) any later version. | |
| 16 | * | |
| 17 | * This program is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 23 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16752
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 5717 | 25 | */ |
| 9791 | 26 | #include "internal.h" |
| 15577 | 27 | #include "pidgin.h" |
| 5717 | 28 | |
| 29 | #include "account.h" | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
30 | #include "debug.h" |
|
6460
fc288e7221ca
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
31 | #include "notify.h" |
| 6216 | 32 | #include "prefs.h" |
| 10643 | 33 | #include "gtkblist.h" |
|
12404
657afdf0f596
[gaim-migrate @ 14711]
Richard Laager <rlaager@pidgin.im>
parents:
12296
diff
changeset
|
34 | #include "gtkconn.h" |
|
657afdf0f596
[gaim-migrate @ 14711]
Richard Laager <rlaager@pidgin.im>
parents:
12296
diff
changeset
|
35 | #include "gtkdialogs.h" |
| 10643 | 36 | #include "gtkstatusbox.h" |
|
15883
969b74a3e27a
According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
Sean Egan <seanegan@pidgin.im>
parents:
15577
diff
changeset
|
37 | #include "pidginstock.h" |
|
12404
657afdf0f596
[gaim-migrate @ 14711]
Richard Laager <rlaager@pidgin.im>
parents:
12296
diff
changeset
|
38 | #include "gtkutils.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
39 | #include "util.h" |
| 5717 | 40 | |
| 14053 | 41 | #define INITIAL_RECON_DELAY_MIN 8000 |
| 42 | #define INITIAL_RECON_DELAY_MAX 60000 | |
| 43 | ||
|
11721
c74083492667
[gaim-migrate @ 14012]
Mark Doliner <markdoliner@pidgin.im>
parents:
11638
diff
changeset
|
44 | #define MAX_RECON_DELAY 600000 |
|
20433
786f26a8dc6f
Make pidgin use report_disconnect_reason rather than report_disconnect, and
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
45 | #define MAX_RACCOON_DELAY "shorter in urban areas" |
| 11523 | 46 | |
| 47 | typedef struct { | |
| 48 | int delay; | |
| 49 | guint timeout; | |
|
15883
969b74a3e27a
According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
Sean Egan <seanegan@pidgin.im>
parents:
15577
diff
changeset
|
50 | } PidginAutoRecon; |
| 11523 | 51 | |
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
52 | /** |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
53 | * Contains accounts that are auto-reconnecting. |
| 15884 | 54 | * The key is a pointer to the PurpleAccount and the |
|
15883
969b74a3e27a
According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
Sean Egan <seanegan@pidgin.im>
parents:
15577
diff
changeset
|
55 | * value is a pointer to a PidginAutoRecon. |
|
13013
fde187d968dc
[gaim-migrate @ 15366]
Mark Doliner <markdoliner@pidgin.im>
parents:
12607
diff
changeset
|
56 | */ |
|
20341
a20de3c1c254
Rename Pidgin's hash table of ongoing autoreconnections to 'auto_reconns'
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
57 | static GHashTable *auto_reconns = NULL; |
| 11523 | 58 | |
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
59 | static void |
| 15884 | 60 | pidgin_connection_connect_progress(PurpleConnection *gc, |
| 5717 | 61 | const char *text, size_t step, size_t step_count) |
| 62 | { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
63 | PidginBuddyList *gtkblist = pidgin_blist_get_default_gtk_blist(); |
| 10643 | 64 | if (!gtkblist) |
| 65 | return; | |
| 15577 | 66 | pidgin_status_box_set_connecting(PIDGIN_STATUS_BOX(gtkblist->statusbox), |
| 15884 | 67 | (purple_connections_get_connecting() != NULL)); |
| 15577 | 68 | pidgin_status_box_pulse_connecting(PIDGIN_STATUS_BOX(gtkblist->statusbox)); |
| 5717 | 69 | } |
|
13756
c7679a3eefb6
[gaim-migrate @ 16165]
Mark Doliner <markdoliner@pidgin.im>
parents:
13732
diff
changeset
|
70 | |
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
71 | static void |
| 15884 | 72 | pidgin_connection_connected(PurpleConnection *gc) |
| 5717 | 73 | { |
| 15884 | 74 | PurpleAccount *account; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
75 | PidginBuddyList *gtkblist; |
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
76 | |
| 15884 | 77 | account = purple_connection_get_account(gc); |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
78 | gtkblist = pidgin_blist_get_default_gtk_blist(); |
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
79 | |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
80 | if (gtkblist != NULL) |
| 15577 | 81 | pidgin_status_box_set_connecting(PIDGIN_STATUS_BOX(gtkblist->statusbox), |
| 15884 | 82 | (purple_connections_get_connecting() != NULL)); |
|
12607
4622f0adedf4
[gaim-migrate @ 14943]
Mark Doliner <markdoliner@pidgin.im>
parents:
12583
diff
changeset
|
83 | |
|
20341
a20de3c1c254
Rename Pidgin's hash table of ongoing autoreconnections to 'auto_reconns'
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
84 | g_hash_table_remove(auto_reconns, account); |
| 5717 | 85 | } |
| 86 | ||
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
87 | static void |
| 15884 | 88 | pidgin_connection_disconnected(PurpleConnection *gc) |
| 5717 | 89 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
90 | PidginBuddyList *gtkblist = pidgin_blist_get_default_gtk_blist(); |
| 10643 | 91 | if (!gtkblist) |
| 92 | return; | |
| 15577 | 93 | pidgin_status_box_set_connecting(PIDGIN_STATUS_BOX(gtkblist->statusbox), |
| 15884 | 94 | (purple_connections_get_connecting() != NULL)); |
|
5883
290fe1d16e60
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
95 | |
| 15884 | 96 | if (purple_connections_get_all() != NULL) |
|
5883
290fe1d16e60
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
97 | return; |
|
290fe1d16e60
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
98 | |
|
16263
27e0ef0f38e6
Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@pidgin.im>
parents:
16254
diff
changeset
|
99 | pidgin_dialogs_destroy_all(); |
| 5717 | 100 | } |
| 101 | ||
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
102 | static void |
| 11523 | 103 | free_auto_recon(gpointer data) |
| 7493 | 104 | { |
|
15883
969b74a3e27a
According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
Sean Egan <seanegan@pidgin.im>
parents:
15577
diff
changeset
|
105 | PidginAutoRecon *info = data; |
|
7912
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
106 | |
| 11523 | 107 | if (info->timeout != 0) |
| 108 | g_source_remove(info->timeout); | |
|
7912
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
109 | |
| 11523 | 110 | g_free(info); |
| 7493 | 111 | } |
| 112 | ||
| 11523 | 113 | static gboolean |
| 114 | do_signon(gpointer data) | |
|
7912
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
115 | { |
| 15884 | 116 | PurpleAccount *account = data; |
|
15883
969b74a3e27a
According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
Sean Egan <seanegan@pidgin.im>
parents:
15577
diff
changeset
|
117 | PidginAutoRecon *info; |
| 15884 | 118 | PurpleStatus *status; |
|
10916
3de20dd2dade
[gaim-migrate @ 12675]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10915
diff
changeset
|
119 | |
| 15884 | 120 | purple_debug_info("autorecon", "do_signon called\n"); |
| 11523 | 121 | g_return_val_if_fail(account != NULL, FALSE); |
|
20341
a20de3c1c254
Rename Pidgin's hash table of ongoing autoreconnections to 'auto_reconns'
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
122 | info = g_hash_table_lookup(auto_reconns, account); |
|
7912
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
123 | |
| 11523 | 124 | if (info) |
| 125 | info->timeout = 0; | |
|
7912
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
126 | |
| 15884 | 127 | status = purple_account_get_active_status(account); |
| 128 | if (purple_status_is_online(status)) | |
|
13375
5ce3cb98de9f
[gaim-migrate @ 15747]
Mark Doliner <markdoliner@pidgin.im>
parents:
13129
diff
changeset
|
129 | { |
| 15884 | 130 | purple_debug_info("autorecon", "calling purple_account_connect\n"); |
| 131 | purple_account_connect(account); | |
| 132 | purple_debug_info("autorecon", "done calling purple_account_connect\n"); | |
|
13375
5ce3cb98de9f
[gaim-migrate @ 15747]
Mark Doliner <markdoliner@pidgin.im>
parents:
13129
diff
changeset
|
133 | } |
|
7912
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
134 | |
| 11523 | 135 | return FALSE; |
|
7912
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
136 | } |
|
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
137 | |
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
138 | static void |
|
20433
786f26a8dc6f
Make pidgin use report_disconnect_reason rather than report_disconnect, and
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
139 | pidgin_connection_report_disconnect_reason (PurpleConnection *gc, |
| 21279 | 140 | PurpleConnectionError reason, |
|
20433
786f26a8dc6f
Make pidgin use report_disconnect_reason rather than report_disconnect, and
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
141 | const char *text) |
| 7399 | 142 | { |
| 15884 | 143 | PurpleAccount *account = NULL; |
|
15883
969b74a3e27a
According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
Sean Egan <seanegan@pidgin.im>
parents:
15577
diff
changeset
|
144 | PidginAutoRecon *info; |
|
20622
30e148be3e2c
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20341
diff
changeset
|
145 | GList *list; |
| 7808 | 146 | |
| 15884 | 147 | account = purple_connection_get_account(gc); |
|
20341
a20de3c1c254
Rename Pidgin's hash table of ongoing autoreconnections to 'auto_reconns'
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
148 | info = g_hash_table_lookup(auto_reconns, account); |
|
7912
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
149 | |
| 21279 | 150 | if (!purple_connection_error_is_fatal (reason)) { |
|
12009
06852325c88f
[gaim-migrate @ 14302]
Mark Doliner <markdoliner@pidgin.im>
parents:
11721
diff
changeset
|
151 | if (info == NULL) { |
|
15883
969b74a3e27a
According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
Sean Egan <seanegan@pidgin.im>
parents:
15577
diff
changeset
|
152 | info = g_new0(PidginAutoRecon, 1); |
|
20341
a20de3c1c254
Rename Pidgin's hash table of ongoing autoreconnections to 'auto_reconns'
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
153 | g_hash_table_insert(auto_reconns, account, info); |
| 14053 | 154 | info->delay = g_random_int_range(INITIAL_RECON_DELAY_MIN, INITIAL_RECON_DELAY_MAX); |
|
7483
08237091e8a5
[gaim-migrate @ 8096]
Mark Doliner <markdoliner@pidgin.im>
parents:
7431
diff
changeset
|
155 | } else { |
| 11523 | 156 | info->delay = MIN(2 * info->delay, MAX_RECON_DELAY); |
| 157 | if (info->timeout != 0) | |
| 158 | g_source_remove(info->timeout); | |
|
7483
08237091e8a5
[gaim-migrate @ 8096]
Mark Doliner <markdoliner@pidgin.im>
parents:
7431
diff
changeset
|
159 | } |
| 11523 | 160 | info->timeout = g_timeout_add(info->delay, do_signon, account); |
| 11559 | 161 | } else { |
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
162 | if (info != NULL) |
|
20341
a20de3c1c254
Rename Pidgin's hash table of ongoing autoreconnections to 'auto_reconns'
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
163 | g_hash_table_remove(auto_reconns, account); |
|
11721
c74083492667
[gaim-migrate @ 14012]
Mark Doliner <markdoliner@pidgin.im>
parents:
11638
diff
changeset
|
164 | |
| 15884 | 165 | purple_account_set_enabled(account, PIDGIN_UI, FALSE); |
| 7399 | 166 | } |
|
20622
30e148be3e2c
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20341
diff
changeset
|
167 | |
|
30e148be3e2c
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20341
diff
changeset
|
168 | /* If we have any open chats, we probably want to rejoin when we get back online. */ |
|
30e148be3e2c
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20341
diff
changeset
|
169 | list = purple_get_chats(); |
|
30e148be3e2c
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20341
diff
changeset
|
170 | while (list) { |
|
30e148be3e2c
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20341
diff
changeset
|
171 | PurpleConversation *conv = list->data; |
|
30e148be3e2c
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20341
diff
changeset
|
172 | list = list->next; |
|
30e148be3e2c
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20341
diff
changeset
|
173 | if (conv->account != account || |
|
30e148be3e2c
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20341
diff
changeset
|
174 | purple_conv_chat_has_left(PURPLE_CONV_CHAT(conv))) |
|
30e148be3e2c
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20341
diff
changeset
|
175 | continue; |
|
30e148be3e2c
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20341
diff
changeset
|
176 | purple_conversation_set_data(conv, "want-to-rejoin", GINT_TO_POINTER(TRUE)); |
|
30e148be3e2c
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20341
diff
changeset
|
177 | } |
| 7399 | 178 | } |
| 179 | ||
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
22089
diff
changeset
|
180 | static void pidgin_connection_network_connected (void) |
| 14758 | 181 | { |
|
21942
8ee08ef6b2a3
Fix a GList being leaked when dealing with network connection/disconnection events.
Daniel Atallah <datallah@pidgin.im>
parents:
21512
diff
changeset
|
182 | GList *list, *l; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
183 | PidginBuddyList *gtkblist = pidgin_blist_get_default_gtk_blist(); |
| 14767 | 184 | |
| 185 | if(gtkblist) | |
| 15577 | 186 | pidgin_status_box_set_network_available(PIDGIN_STATUS_BOX(gtkblist->statusbox), TRUE); |
| 14767 | 187 | |
|
21942
8ee08ef6b2a3
Fix a GList being leaked when dealing with network connection/disconnection events.
Daniel Atallah <datallah@pidgin.im>
parents:
21512
diff
changeset
|
188 | l = list = purple_accounts_get_all_active(); |
|
8ee08ef6b2a3
Fix a GList being leaked when dealing with network connection/disconnection events.
Daniel Atallah <datallah@pidgin.im>
parents:
21512
diff
changeset
|
189 | while (l) { |
|
8ee08ef6b2a3
Fix a GList being leaked when dealing with network connection/disconnection events.
Daniel Atallah <datallah@pidgin.im>
parents:
21512
diff
changeset
|
190 | PurpleAccount *account = (PurpleAccount*)l->data; |
|
20341
a20de3c1c254
Rename Pidgin's hash table of ongoing autoreconnections to 'auto_reconns'
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
191 | g_hash_table_remove(auto_reconns, account); |
| 15884 | 192 | if (purple_account_is_disconnected(account)) |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14767
diff
changeset
|
193 | do_signon(account); |
|
21942
8ee08ef6b2a3
Fix a GList being leaked when dealing with network connection/disconnection events.
Daniel Atallah <datallah@pidgin.im>
parents:
21512
diff
changeset
|
194 | l = l->next; |
| 14767 | 195 | } |
|
21942
8ee08ef6b2a3
Fix a GList being leaked when dealing with network connection/disconnection events.
Daniel Atallah <datallah@pidgin.im>
parents:
21512
diff
changeset
|
196 | g_list_free(list); |
| 14758 | 197 | } |
| 198 | ||
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
22089
diff
changeset
|
199 | static void pidgin_connection_network_disconnected (void) |
| 14758 | 200 | { |
|
21942
8ee08ef6b2a3
Fix a GList being leaked when dealing with network connection/disconnection events.
Daniel Atallah <datallah@pidgin.im>
parents:
21512
diff
changeset
|
201 | GList *list, *l; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
202 | PidginBuddyList *gtkblist = pidgin_blist_get_default_gtk_blist(); |
|
21942
8ee08ef6b2a3
Fix a GList being leaked when dealing with network connection/disconnection events.
Daniel Atallah <datallah@pidgin.im>
parents:
21512
diff
changeset
|
203 | |
| 14767 | 204 | if(gtkblist) |
| 15577 | 205 | pidgin_status_box_set_network_available(PIDGIN_STATUS_BOX(gtkblist->statusbox), FALSE); |
| 14767 | 206 | |
|
21942
8ee08ef6b2a3
Fix a GList being leaked when dealing with network connection/disconnection events.
Daniel Atallah <datallah@pidgin.im>
parents:
21512
diff
changeset
|
207 | l = list = purple_accounts_get_all_active(); |
| 14758 | 208 | while (l) { |
| 15884 | 209 | PurpleAccount *a = (PurpleAccount*)l->data; |
| 210 | if (!purple_account_is_disconnected(a)) { | |
|
23051
aab1ad3434f2
Disconnect accounts immediately when we're told the network has
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
211 | purple_account_disconnect(a); |
| 15090 | 212 | } |
| 14758 | 213 | l = l->next; |
| 214 | } | |
|
21942
8ee08ef6b2a3
Fix a GList being leaked when dealing with network connection/disconnection events.
Daniel Atallah <datallah@pidgin.im>
parents:
21512
diff
changeset
|
215 | g_list_free(list); |
| 14758 | 216 | } |
| 217 | ||
| 15884 | 218 | static void pidgin_connection_notice(PurpleConnection *gc, const char *text) |
| 14758 | 219 | { } |
| 220 | ||
| 15884 | 221 | static PurpleConnectionUiOps conn_ui_ops = |
| 5717 | 222 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
223 | pidgin_connection_connect_progress, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
224 | pidgin_connection_connected, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
225 | pidgin_connection_disconnected, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
226 | pidgin_connection_notice, |
|
20433
786f26a8dc6f
Make pidgin use report_disconnect_reason rather than report_disconnect, and
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
227 | NULL, /* report_disconnect */ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
228 | pidgin_connection_network_connected, |
|
16752
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16263
diff
changeset
|
229 | pidgin_connection_network_disconnected, |
|
20433
786f26a8dc6f
Make pidgin use report_disconnect_reason rather than report_disconnect, and
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
230 | pidgin_connection_report_disconnect_reason, |
|
16752
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16263
diff
changeset
|
231 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16263
diff
changeset
|
232 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16263
diff
changeset
|
233 | NULL |
| 5717 | 234 | }; |
| 235 | ||
| 15884 | 236 | PurpleConnectionUiOps * |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
237 | pidgin_connections_get_ui_ops(void) |
| 5717 | 238 | { |
| 239 | return &conn_ui_ops; | |
| 240 | } | |
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
241 | |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
242 | static void |
| 15884 | 243 | account_removed_cb(PurpleAccount *account, gpointer user_data) |
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
244 | { |
|
20341
a20de3c1c254
Rename Pidgin's hash table of ongoing autoreconnections to 'auto_reconns'
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
245 | g_hash_table_remove(auto_reconns, account); |
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
246 | } |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
247 | |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
248 | |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
249 | /************************************************************************** |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
250 | * GTK+ connection glue |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
251 | **************************************************************************/ |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
252 | |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
253 | void * |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
254 | pidgin_connection_get_handle(void) |
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
255 | { |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
256 | static int handle; |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
257 | |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
258 | return &handle; |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
259 | } |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
260 | |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
261 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
262 | pidgin_connection_init(void) |
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
263 | { |
|
20341
a20de3c1c254
Rename Pidgin's hash table of ongoing autoreconnections to 'auto_reconns'
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
264 | auto_reconns = g_hash_table_new_full( |
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
265 | g_direct_hash, g_direct_equal, |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
266 | NULL, free_auto_recon); |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
267 | |
| 15884 | 268 | purple_signal_connect(purple_accounts_get_handle(), "account-removed", |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
269 | pidgin_connection_get_handle(), |
| 15884 | 270 | PURPLE_CALLBACK(account_removed_cb), NULL); |
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
271 | } |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
272 | |
|
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
273 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
274 | pidgin_connection_uninit(void) |
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
275 | { |
| 15884 | 276 | purple_signals_disconnect_by_handle(pidgin_connection_get_handle()); |
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
277 | |
|
20341
a20de3c1c254
Rename Pidgin's hash table of ongoing autoreconnections to 'auto_reconns'
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
278 | g_hash_table_destroy(auto_reconns); |
|
13014
fa17f785b6fe
[gaim-migrate @ 15367]
Mark Doliner <markdoliner@pidgin.im>
parents:
13013
diff
changeset
|
279 | } |