Mercurial > pidgin.yaz
annotate finch/gntconn.c @ 24872:fc07bafe9e9b
update German translation
author | Jochen Kemnade <jochenkemnade@web.de> |
---|---|
date | Sun, 04 Jan 2009 11:30:12 +0000 |
parents | 07c2b8fa7bb4 |
children | f7c5bb2f6623 |
rev | line source |
---|---|
15818 | 1 /** |
2 * @file gntconn.c GNT Connection API | |
16194
0f0832c13fcb
Rename the Doxygen group from gntui to finch and define the finch group
Richard Laager <rlaager@wiktel.com>
parents:
15871
diff
changeset
|
3 * @ingroup finch |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
20053
diff
changeset
|
4 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
20053
diff
changeset
|
5 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
20053
diff
changeset
|
6 /* finch |
15818 | 7 * |
15871
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
8 * Finch is the legal property of its developers, whose names are too numerous |
15818 | 9 * to list here. Please refer to the COPYRIGHT file distributed with this |
10 * source distribution. | |
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 | |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18210
diff
changeset
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15818 | 25 */ |
18210
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
17878
diff
changeset
|
26 #include "finch.h" |
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
17878
diff
changeset
|
27 |
15818 | 28 #include "account.h" |
29 #include "core.h" | |
17878
392889212240
#include "connection.h" instead of "connection.c". I don't care if this
Stu Tomlinson <stu@nosnilmot.com>
parents:
17419
diff
changeset
|
30 #include "connection.h" |
17419
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
31 #include "debug.h" |
15818 | 32 #include "request.h" |
33 | |
19944
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
34 #include "gntaccount.h" |
15818 | 35 #include "gntconn.h" |
36 | |
17419
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
37 #define INITIAL_RECON_DELAY_MIN 8000 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
38 #define INITIAL_RECON_DELAY_MAX 60000 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
39 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
40 #define MAX_RECON_DELAY 600000 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
41 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
42 typedef struct { |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
43 int delay; |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
44 guint timeout; |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
45 } FinchAutoRecon; |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
46 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
47 /** |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
48 * Contains accounts that are auto-reconnecting. |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
49 * The key is a pointer to the PurpleAccount and the |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
50 * value is a pointer to a FinchAutoRecon. |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
51 */ |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
52 static GHashTable *hash = NULL; |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
53 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
54 static void |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
55 free_auto_recon(gpointer data) |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
56 { |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
57 FinchAutoRecon *info = data; |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
58 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
59 if (info->timeout != 0) |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
60 g_source_remove(info->timeout); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
61 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
62 g_free(info); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
63 } |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
64 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
65 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
66 static gboolean |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
67 do_signon(gpointer data) |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
68 { |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
69 PurpleAccount *account = data; |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
70 FinchAutoRecon *info; |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
71 PurpleStatus *status; |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
72 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
73 purple_debug_info("autorecon", "do_signon called\n"); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
74 g_return_val_if_fail(account != NULL, FALSE); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
75 info = g_hash_table_lookup(hash, account); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
76 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
77 if (info) |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
78 info->timeout = 0; |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
79 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
80 status = purple_account_get_active_status(account); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
81 if (purple_status_is_online(status)) |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
82 { |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
83 purple_debug_info("autorecon", "calling purple_account_connect\n"); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
84 purple_account_connect(account); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
85 purple_debug_info("autorecon", "done calling purple_account_connect\n"); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
86 } |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
87 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
88 return FALSE; |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
89 } |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
90 |
15818 | 91 static void |
19944
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
92 ce_modify_account_cb(PurpleAccount *account) |
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
93 { |
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
94 finch_account_dialog_show(account); |
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
95 } |
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
96 |
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
97 static void |
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
98 ce_enable_account_cb(PurpleAccount *account) |
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
99 { |
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
100 purple_account_set_enabled(account, FINCH_UI, TRUE); |
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
101 } |
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
102 |
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
103 static void |
22214
2b426862ffbf
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21627
diff
changeset
|
104 finch_connection_report_disconnect(PurpleConnection *gc, PurpleConnectionError reason, |
2b426862ffbf
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21627
diff
changeset
|
105 const char *text) |
15818 | 106 { |
17419
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
107 FinchAutoRecon *info; |
15823 | 108 PurpleAccount *account = purple_connection_get_account(gc); |
20053
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19944
diff
changeset
|
109 GList *list; |
15818 | 110 |
22214
2b426862ffbf
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21627
diff
changeset
|
111 if (!purple_connection_error_is_fatal(reason)) { |
20053
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19944
diff
changeset
|
112 info = g_hash_table_lookup(hash, account); |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19944
diff
changeset
|
113 |
17419
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
114 if (info == NULL) { |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
115 info = g_new0(FinchAutoRecon, 1); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
116 g_hash_table_insert(hash, account, info); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
117 info->delay = g_random_int_range(INITIAL_RECON_DELAY_MIN, INITIAL_RECON_DELAY_MAX); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
118 } else { |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
119 info->delay = MIN(2 * info->delay, MAX_RECON_DELAY); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
120 if (info->timeout != 0) |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
121 g_source_remove(info->timeout); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
122 } |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
123 info->timeout = g_timeout_add(info->delay, do_signon, account); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
124 } else { |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
125 char *act, *primary, *secondary; |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
126 act = g_strdup_printf(_("%s (%s)"), purple_account_get_username(account), |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
127 purple_account_get_protocol_name(account)); |
15818 | 128 |
17419
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
129 primary = g_strdup_printf(_("%s disconnected."), act); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
130 secondary = g_strdup_printf(_("%s\n\n" |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
131 "Finch will not attempt to reconnect the account until you " |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
132 "correct the error and re-enable the account."), text); |
19944
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
133 |
21570
dccfd999ffe7
merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents:
21244
diff
changeset
|
134 purple_request_action(account, NULL, primary, secondary, 2, |
19944
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
135 account, NULL, NULL, |
21570
dccfd999ffe7
merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents:
21244
diff
changeset
|
136 account, 3, |
19944
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
137 _("OK"), NULL, |
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
138 _("Modify Account"), PURPLE_CALLBACK(ce_modify_account_cb), |
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
139 _("Re-enable Account"), PURPLE_CALLBACK(ce_enable_account_cb)); |
17419
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
140 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
141 g_free(act); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
142 g_free(primary); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
143 g_free(secondary); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
144 purple_account_set_enabled(account, FINCH_UI, FALSE); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
145 } |
20053
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19944
diff
changeset
|
146 |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19944
diff
changeset
|
147 /* If we have any open chats, we probably want to rejoin when we get back online. */ |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19944
diff
changeset
|
148 list = purple_get_chats(); |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19944
diff
changeset
|
149 while (list) { |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19944
diff
changeset
|
150 PurpleConversation *conv = list->data; |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19944
diff
changeset
|
151 list = list->next; |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
152 if (purple_conversation_get_account(conv) != account || |
20053
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19944
diff
changeset
|
153 purple_conv_chat_has_left(PURPLE_CONV_CHAT(conv))) |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19944
diff
changeset
|
154 continue; |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19944
diff
changeset
|
155 purple_conversation_set_data(conv, "want-to-rejoin", GINT_TO_POINTER(TRUE)); |
21627
9f7590a24b9b
Show a helpful message about account disconnect. Someone should come up with a better string.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21570
diff
changeset
|
156 purple_conversation_write(conv, NULL, _("The account has disconnected and you are no " |
9f7590a24b9b
Show a helpful message about account disconnect. Someone should come up with a better string.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21570
diff
changeset
|
157 "longer in this chat. You will be automatically rejoined in the chat when " |
9f7590a24b9b
Show a helpful message about account disconnect. Someone should come up with a better string.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21570
diff
changeset
|
158 "the account reconnects."), |
9f7590a24b9b
Show a helpful message about account disconnect. Someone should come up with a better string.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21570
diff
changeset
|
159 PURPLE_MESSAGE_SYSTEM, time(NULL)); |
20053
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19944
diff
changeset
|
160 } |
17419
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
161 } |
15818 | 162 |
17419
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
163 static void |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
164 account_removed_cb(PurpleAccount *account, gpointer user_data) |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
165 { |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
166 g_hash_table_remove(hash, account); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
167 } |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
168 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
169 static void * |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
170 finch_connection_get_handle(void) |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
171 { |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
172 static int handle; |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
173 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
174 return &handle; |
15818 | 175 } |
176 | |
15823 | 177 static PurpleConnectionUiOps ops = |
15818 | 178 { |
17104
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16442
diff
changeset
|
179 NULL, /* connect_progress */ |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16442
diff
changeset
|
180 NULL, /* connected */ |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16442
diff
changeset
|
181 NULL, /* disconnected */ |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16442
diff
changeset
|
182 NULL, /* notice */ |
22214
2b426862ffbf
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21627
diff
changeset
|
183 NULL, |
17104
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16442
diff
changeset
|
184 NULL, /* network_connected */ |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16442
diff
changeset
|
185 NULL, /* network_disconnected */ |
22214
2b426862ffbf
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21627
diff
changeset
|
186 finch_connection_report_disconnect, |
17104
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16442
diff
changeset
|
187 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16442
diff
changeset
|
188 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16442
diff
changeset
|
189 NULL |
15818 | 190 }; |
191 | |
15823 | 192 PurpleConnectionUiOps *finch_connections_get_ui_ops() |
15818 | 193 { |
194 return &ops; | |
195 } | |
196 | |
197 void finch_connections_init() | |
17419
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
198 { |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
199 hash = g_hash_table_new_full( |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
200 g_direct_hash, g_direct_equal, |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
201 NULL, free_auto_recon); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
202 |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
203 purple_signal_connect(purple_accounts_get_handle(), "account-removed", |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
204 finch_connection_get_handle(), |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
205 PURPLE_CALLBACK(account_removed_cb), NULL); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
206 } |
15818 | 207 |
208 void finch_connections_uninit() | |
17419
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
209 { |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
210 purple_signals_disconnect_by_handle(finch_connection_get_handle()); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
211 g_hash_table_destroy(hash); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
212 } |