Fri, 15 Jun 2007 01:54:23 +0000
#include "connection.h" instead of "connection.c". I don't care if this
compiles, it's clearly more correct.
|
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 |
|
14620
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
4 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15906
diff
changeset
|
5 | * finch |
|
14620
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
6 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15906
diff
changeset
|
7 | * 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
|
8 | * 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
|
9 | * source distribution. |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
10 | * |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
11 | * 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
|
12 | * 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
|
13 | * 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
|
14 | * (at your option) any later version. |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
15 | * |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
16 | * 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
|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
19 | * GNU General Public License for more details. |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
20 | * |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
21 | * 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
|
22 | * along with this program; if not, write to the Free Software |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
90d599495d65
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14014
diff
changeset
|
24 | */ |
|
15781
7ebe22110a73
Add a 'Reconnect' button in the 'account was disconnected.' dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14620
diff
changeset
|
25 | #include "account.h" |
|
7ebe22110a73
Add a 'Reconnect' button in the 'account was disconnected.' dialog.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14620
diff
changeset
|
26 | #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
|
27 | #include "connection.h" |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
28 | #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
|
29 | #include "request.h" |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
30 | |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
31 | #include "gntconn.h" |
| 15884 | 32 | #include "finch.h" |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
33 | |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
34 | #define INITIAL_RECON_DELAY_MIN 8000 |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
35 | #define INITIAL_RECON_DELAY_MAX 60000 |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
36 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
37 | #define MAX_RECON_DELAY 600000 |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
38 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
39 | typedef struct { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
40 | int delay; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
41 | guint timeout; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
42 | } FinchAutoRecon; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
43 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
44 | /** |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
45 | * Contains accounts that are auto-reconnecting. |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
46 | * 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
|
47 | * value is a pointer to a FinchAutoRecon. |
|
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 | static GHashTable *hash = NULL; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
50 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
51 | static void |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
52 | free_auto_recon(gpointer data) |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
53 | { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
54 | FinchAutoRecon *info = data; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
55 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
56 | if (info->timeout != 0) |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
57 | g_source_remove(info->timeout); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
58 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
59 | g_free(info); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
60 | } |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
61 | |
|
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 | static gboolean |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
64 | do_signon(gpointer data) |
|
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 | PurpleAccount *account = data; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
67 | FinchAutoRecon *info; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
68 | PurpleStatus *status; |
|
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 | 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
|
71 | 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
|
72 | info = g_hash_table_lookup(hash, account); |
|
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 | if (info) |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
75 | info->timeout = 0; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
76 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
77 | status = purple_account_get_active_status(account); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
78 | if (purple_status_is_online(status)) |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
79 | { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
80 | 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
|
81 | purple_account_connect(account); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
82 | 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
|
83 | } |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
84 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
85 | return FALSE; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
86 | } |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
87 | |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
88 | static void |
| 15884 | 89 | finch_connection_report_disconnect(PurpleConnection *gc, const char *text) |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
90 | { |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
91 | FinchAutoRecon *info; |
| 15884 | 92 | PurpleAccount *account = purple_connection_get_account(gc); |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
93 | |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
94 | info = g_hash_table_lookup(hash, account); |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
95 | |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
96 | if (!gc->wants_to_die) { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
97 | if (info == NULL) { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
98 | info = g_new0(FinchAutoRecon, 1); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
99 | g_hash_table_insert(hash, account, info); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
100 | 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
|
101 | } else { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
102 | 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
|
103 | if (info->timeout != 0) |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
104 | g_source_remove(info->timeout); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
105 | } |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
106 | 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
|
107 | } else { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
108 | char *act, *primary, *secondary; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
109 | 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
|
110 | purple_account_get_protocol_name(account)); |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
111 | |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
112 | primary = g_strdup_printf(_("%s disconnected."), act); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
113 | secondary = g_strdup_printf(_("%s\n\n" |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
114 | "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
|
115 | "correct the error and re-enable the account."), text); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
116 | purple_notify_error(NULL, NULL, primary, secondary); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
117 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
118 | g_free(act); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
119 | g_free(primary); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
120 | g_free(secondary); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
121 | 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
|
122 | } |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
123 | } |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
124 | |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
125 | static void |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
126 | 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
|
127 | { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
128 | g_hash_table_remove(hash, account); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
129 | } |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
130 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
131 | static void * |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
132 | finch_connection_get_handle(void) |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
133 | { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
134 | static int handle; |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
135 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
136 | return &handle; |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
137 | } |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
138 | |
| 15884 | 139 | static PurpleConnectionUiOps ops = |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
140 | { |
|
17164
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
141 | NULL, /* connect_progress */ |
|
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
142 | NULL, /* connected */ |
|
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
143 | NULL, /* disconnected */ |
|
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
144 | NULL, /* notice */ |
|
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
145 | finch_connection_report_disconnect, |
|
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
146 | NULL, /* network_connected */ |
|
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
147 | NULL, /* network_disconnected */ |
|
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
148 | NULL, |
|
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
149 | NULL, |
|
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
150 | NULL, |
|
3a005b9e8f28
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
151 | NULL |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
152 | }; |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
153 | |
| 15884 | 154 | PurpleConnectionUiOps *finch_connections_get_ui_ops() |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
155 | { |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
156 | return &ops; |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
157 | } |
|
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
158 | |
|
15878
f52832b611fe
renamed gaim-text to finch
Sean Egan <seanegan@pidgin.im>
parents:
15781
diff
changeset
|
159 | void finch_connections_init() |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
160 | { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
161 | hash = g_hash_table_new_full( |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
162 | g_direct_hash, g_direct_equal, |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
163 | NULL, free_auto_recon); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
164 | |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
165 | 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
|
166 | finch_connection_get_handle(), |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
167 | PURPLE_CALLBACK(account_removed_cb), NULL); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
168 | } |
|
14014
223d99ce2f06
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
169 | |
|
15878
f52832b611fe
renamed gaim-text to finch
Sean Egan <seanegan@pidgin.im>
parents:
15781
diff
changeset
|
170 | void finch_connections_uninit() |
|
17401
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
171 | { |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
172 | 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
|
173 | g_hash_table_destroy(hash); |
|
4db9d9d3e928
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17164
diff
changeset
|
174 | } |