Tue, 04 Jan 2011 06:55:30 +0000
Remove trailing whitespace
|
14620
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
1 | /** |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
2 | * @file gntconn.c GNT Connection API |
|
16255
fa61ee19f526
Rename the Doxygen group from gntui to finch and define the finch group
Richard Laager <rlaager@pidgin.im>
parents:
15931
diff
changeset
|
3 | * @ingroup finch |
|
20330
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
20315
diff
changeset
|
4 | */ |
|
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
20315
diff
changeset
|
5 | |
|
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
20315
diff
changeset
|
6 | /* finch |
|
14620
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
7 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15906
diff
changeset
|
8 | * Finch is the legal property of its developers, whose names are too numerous |
|
14620
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
10 | * source distribution. |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
11 | * |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
12 | * This program is free software; you can redistribute it and/or modify |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
13 | * it under the terms of the GNU General Public License as published by |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
14 | * the Free Software Foundation; either version 2 of the License, or |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
15 | * (at your option) any later version. |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
16 | * |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
17 | * This program is distributed in the hope that it will be useful, |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
20 | * GNU General Public License for more details. |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
21 | * |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
22 | * You should have received a copy of the GNU General Public License |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
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:
18273
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
14620
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
25 | */ |
|
29106
51c7b2177e42
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <darkrain42@pidgin.im>
parents:
28716
diff
changeset
|
26 | #include <internal.h> |
|
18273
e61c53184c52
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17746
diff
changeset
|
27 | #include "finch.h" |
|
e61c53184c52
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17746
diff
changeset
|
28 | |
|
15781
7ebe22110a73
Add a 'Reconnect' button in the 'account was disconnected.' dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14620
diff
changeset
|
29 | #include "account.h" |
|
7ebe22110a73
Add a 'Reconnect' button in the 'account was disconnected.' dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14620
diff
changeset
|
30 | #include "core.h" |
|
17746
3b1443cb4bfa
#include "connection.h" instead of "connection.c". I don't care if this
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17401
diff
changeset
|
31 | #include "connection.h" |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
32 | #include "debug.h" |
|
15781
7ebe22110a73
Add a 'Reconnect' button in the 'account was disconnected.' dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14620
diff
changeset
|
33 | #include "request.h" |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
34 | |
|
19969
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
35 | #include "gntaccount.h" |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
36 | #include "gntconn.h" |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
37 | |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
38 | #define INITIAL_RECON_DELAY_MIN 8000 |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
39 | #define INITIAL_RECON_DELAY_MAX 60000 |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
40 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
41 | #define MAX_RECON_DELAY 600000 |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
42 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
43 | typedef struct { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
44 | int delay; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
45 | guint timeout; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
46 | } FinchAutoRecon; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
47 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
48 | /** |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
49 | * Contains accounts that are auto-reconnecting. |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
50 | * The key is a pointer to the PurpleAccount and the |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
51 | * value is a pointer to a FinchAutoRecon. |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
52 | */ |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
53 | static GHashTable *hash = NULL; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
54 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
55 | static void |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
56 | free_auto_recon(gpointer data) |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
57 | { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
58 | FinchAutoRecon *info = data; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
59 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
60 | if (info->timeout != 0) |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
61 | g_source_remove(info->timeout); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
62 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
63 | g_free(info); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
64 | } |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
65 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
66 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
67 | static gboolean |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
68 | do_signon(gpointer data) |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
69 | { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
70 | PurpleAccount *account = data; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
71 | FinchAutoRecon *info; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
72 | PurpleStatus *status; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
73 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
74 | purple_debug_info("autorecon", "do_signon called\n"); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
75 | g_return_val_if_fail(account != NULL, FALSE); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
76 | info = g_hash_table_lookup(hash, account); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
77 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
78 | if (info) |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
79 | info->timeout = 0; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
80 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
81 | status = purple_account_get_active_status(account); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
82 | if (purple_status_is_online(status)) |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
83 | { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
84 | purple_debug_info("autorecon", "calling purple_account_connect\n"); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
85 | purple_account_connect(account); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
86 | purple_debug_info("autorecon", "done calling purple_account_connect\n"); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
87 | } |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
88 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
89 | return FALSE; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
90 | } |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
91 | |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
92 | static void |
|
19969
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
93 | ce_modify_account_cb(PurpleAccount *account) |
|
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
94 | { |
|
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
95 | finch_account_dialog_show(account); |
|
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
96 | } |
|
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
97 | |
|
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
98 | static void |
|
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
99 | ce_enable_account_cb(PurpleAccount *account) |
|
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
100 | { |
|
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
101 | purple_account_set_enabled(account, FINCH_UI, TRUE); |
|
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
102 | } |
|
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
103 | |
|
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
104 | static void |
|
22336
ac905bb0a8ec
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21756
diff
changeset
|
105 | finch_connection_report_disconnect(PurpleConnection *gc, PurpleConnectionError reason, |
|
ac905bb0a8ec
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21756
diff
changeset
|
106 | const char *text) |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
107 | { |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
108 | FinchAutoRecon *info; |
| 15884 | 109 | PurpleAccount *account = purple_connection_get_account(gc); |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
110 | |
|
22336
ac905bb0a8ec
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21756
diff
changeset
|
111 | if (!purple_connection_error_is_fatal(reason)) { |
|
20315
21fbfe31160a
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19969
diff
changeset
|
112 | info = g_hash_table_lookup(hash, account); |
|
21fbfe31160a
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19969
diff
changeset
|
113 | |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
114 | if (info == NULL) { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
115 | info = g_new0(FinchAutoRecon, 1); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
116 | g_hash_table_insert(hash, account, info); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
117 | info->delay = g_random_int_range(INITIAL_RECON_DELAY_MIN, INITIAL_RECON_DELAY_MAX); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
118 | } else { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
119 | info->delay = MIN(2 * info->delay, MAX_RECON_DELAY); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
120 | if (info->timeout != 0) |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
121 | g_source_remove(info->timeout); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
122 | } |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
123 | info->timeout = g_timeout_add(info->delay, do_signon, account); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
124 | } else { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
125 | char *act, *primary, *secondary; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
126 | act = g_strdup_printf(_("%s (%s)"), purple_account_get_username(account), |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
127 | purple_account_get_protocol_name(account)); |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
128 | |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
129 | primary = g_strdup_printf(_("%s disconnected."), act); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
130 | secondary = g_strdup_printf(_("%s\n\n" |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
131 | "Finch will not attempt to reconnect the account until you " |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
132 | "correct the error and re-enable the account."), text); |
|
19969
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
133 | |
|
21653
621c47778132
merge of '73ae9aeda3c58fbf8437421da68d19d06f93e686'
Evan Schoenberg <evands@pidgin.im>
parents:
21233
diff
changeset
|
134 | purple_request_action(account, NULL, primary, secondary, 2, |
|
19969
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
135 | account, NULL, NULL, |
|
21653
621c47778132
merge of '73ae9aeda3c58fbf8437421da68d19d06f93e686'
Evan Schoenberg <evands@pidgin.im>
parents:
21233
diff
changeset
|
136 | account, 3, |
|
19969
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
137 | _("OK"), NULL, |
|
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
138 | _("Modify Account"), PURPLE_CALLBACK(ce_modify_account_cb), |
|
53aca1037b2c
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
139 | _("Re-enable Account"), PURPLE_CALLBACK(ce_enable_account_cb)); |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
140 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
141 | g_free(act); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
142 | g_free(primary); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
143 | g_free(secondary); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
144 | purple_account_set_enabled(account, FINCH_UI, FALSE); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
145 | } |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
146 | } |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
147 | |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
148 | static void |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
149 | account_removed_cb(PurpleAccount *account, gpointer user_data) |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
150 | { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
151 | g_hash_table_remove(hash, account); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
152 | } |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
153 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
154 | static void * |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
155 | finch_connection_get_handle(void) |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
156 | { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
157 | static int handle; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
158 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
159 | return &handle; |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
160 | } |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
161 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29106
diff
changeset
|
162 | static PurpleConnectionUiOps ops = |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
163 | { |
|
17164
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
164 | NULL, /* connect_progress */ |
|
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
165 | NULL, /* connected */ |
|
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
166 | NULL, /* disconnected */ |
|
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
167 | NULL, /* notice */ |
|
22336
ac905bb0a8ec
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21756
diff
changeset
|
168 | NULL, |
|
17164
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
169 | NULL, /* network_connected */ |
|
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
170 | NULL, /* network_disconnected */ |
|
22336
ac905bb0a8ec
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21756
diff
changeset
|
171 | finch_connection_report_disconnect, |
|
17164
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
172 | NULL, |
|
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
173 | NULL, |
|
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
174 | NULL |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
175 | }; |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
176 | |
| 15884 | 177 | PurpleConnectionUiOps *finch_connections_get_ui_ops() |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
178 | { |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
179 | return &ops; |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
180 | } |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
181 | |
|
15878
f52832b611fe
renamed gaim-text to finch
Sean Egan <seanegan@pidgin.im>
parents:
15781
diff
changeset
|
182 | void finch_connections_init() |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
183 | { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
184 | hash = g_hash_table_new_full( |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
185 | g_direct_hash, g_direct_equal, |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
186 | NULL, free_auto_recon); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
187 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
188 | purple_signal_connect(purple_accounts_get_handle(), "account-removed", |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
189 | finch_connection_get_handle(), |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
190 | PURPLE_CALLBACK(account_removed_cb), NULL); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
191 | } |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
192 | |
|
15878
f52832b611fe
renamed gaim-text to finch
Sean Egan <seanegan@pidgin.im>
parents:
15781
diff
changeset
|
193 | void finch_connections_uninit() |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
194 | { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
195 | purple_signals_disconnect_by_handle(finch_connection_get_handle()); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
196 | g_hash_table_destroy(hash); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
197 | } |