annotate finch/gntconn.c @ 18383:9eb2f4d27990

Use the completion-signal to append a ': ' after a tab-completed nick.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 30 Jun 2007 06:45:59 +0000
parents b8572b937c09
children 44b4e8bd759b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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: 15870
diff changeset
3 * @ingroup finch
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 *
15870
66dff3dfdea6 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents: 15822
diff changeset
5 * finch
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 *
15870
66dff3dfdea6 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents: 15822
diff changeset
7 * Finch is the legal property of its developers, whose names are too numerous
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * source distribution.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * (at your option) any later version.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * GNU General Public License for more details.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 */
18210
b8572b937c09 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents: 17639
diff changeset
25 #include "finch.h"
b8572b937c09 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents: 17639
diff changeset
26
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "account.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "core.h"
17639
392889212240 #include "connection.h" instead of "connection.c". I don't care if this
Stu Tomlinson <stu@nosnilmot.com>
parents: 17346
diff changeset
29 #include "connection.h"
17346
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
30 #include "debug.h"
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "request.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "gntconn.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34
17346
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
35 #define INITIAL_RECON_DELAY_MIN 8000
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
36 #define INITIAL_RECON_DELAY_MAX 60000
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
37
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
38 #define MAX_RECON_DELAY 600000
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
39
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
40 typedef struct {
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
41 int delay;
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
42 guint timeout;
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
43 } FinchAutoRecon;
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
44
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
45 /**
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
46 * Contains accounts that are auto-reconnecting.
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
47 * The key is a pointer to the PurpleAccount and the
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
48 * value is a pointer to a FinchAutoRecon.
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
49 */
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
50 static GHashTable *hash = NULL;
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
51
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
52 static void
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
53 free_auto_recon(gpointer data)
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
54 {
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
55 FinchAutoRecon *info = data;
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
56
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
57 if (info->timeout != 0)
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
58 g_source_remove(info->timeout);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
59
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
60 g_free(info);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
61 }
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
62
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
63
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
64 static gboolean
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
65 do_signon(gpointer data)
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
66 {
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
67 PurpleAccount *account = data;
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
68 FinchAutoRecon *info;
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
69 PurpleStatus *status;
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
70
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
71 purple_debug_info("autorecon", "do_signon called\n");
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
72 g_return_val_if_fail(account != NULL, FALSE);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
73 info = g_hash_table_lookup(hash, account);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
74
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
75 if (info)
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
76 info->timeout = 0;
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
77
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
78 status = purple_account_get_active_status(account);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
79 if (purple_status_is_online(status))
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
80 {
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
81 purple_debug_info("autorecon", "calling purple_account_connect\n");
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
82 purple_account_connect(account);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
83 purple_debug_info("autorecon", "done calling purple_account_connect\n");
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
84 }
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
85
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
86 return FALSE;
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
87 }
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
88
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
90 finch_connection_report_disconnect(PurpleConnection *gc, const char *text)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 {
17346
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
92 FinchAutoRecon *info;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
93 PurpleAccount *account = purple_connection_get_account(gc);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94
17346
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
95 info = g_hash_table_lookup(hash, account);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96
17346
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
97 if (!gc->wants_to_die) {
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
98 if (info == NULL) {
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
99 info = g_new0(FinchAutoRecon, 1);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
100 g_hash_table_insert(hash, account, info);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
101 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: 17091
diff changeset
102 } else {
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
103 info->delay = MIN(2 * info->delay, MAX_RECON_DELAY);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
104 if (info->timeout != 0)
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
105 g_source_remove(info->timeout);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
106 }
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
107 info->timeout = g_timeout_add(info->delay, do_signon, account);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
108 } else {
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
109 char *act, *primary, *secondary;
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
110 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: 17091
diff changeset
111 purple_account_get_protocol_name(account));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112
17346
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
113 primary = g_strdup_printf(_("%s disconnected."), act);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
114 secondary = g_strdup_printf(_("%s\n\n"
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
115 "Finch will not attempt to reconnect the account until you "
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
116 "correct the error and re-enable the account."), text);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
117 purple_notify_error(NULL, NULL, primary, secondary);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
118
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
119 g_free(act);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
120 g_free(primary);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
121 g_free(secondary);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
122 purple_account_set_enabled(account, FINCH_UI, FALSE);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
123 }
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
124 }
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125
17346
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
126 static void
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
127 account_removed_cb(PurpleAccount *account, gpointer user_data)
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
128 {
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
129 g_hash_table_remove(hash, account);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
130 }
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
131
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
132 static void *
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
133 finch_connection_get_handle(void)
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
134 {
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
135 static int handle;
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
136
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
137 return &handle;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
140 static PurpleConnectionUiOps ops =
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 {
17091
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16439
diff changeset
142 NULL, /* connect_progress */
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16439
diff changeset
143 NULL, /* connected */
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16439
diff changeset
144 NULL, /* disconnected */
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16439
diff changeset
145 NULL, /* notice */
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16439
diff changeset
146 finch_connection_report_disconnect,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16439
diff changeset
147 NULL, /* network_connected */
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16439
diff changeset
148 NULL, /* network_disconnected */
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16439
diff changeset
149 NULL,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16439
diff changeset
150 NULL,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16439
diff changeset
151 NULL,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16439
diff changeset
152 NULL
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 };
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
155 PurpleConnectionUiOps *finch_connections_get_ui_ops()
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 return &ops;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 void finch_connections_init()
17346
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
161 {
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
162 hash = g_hash_table_new_full(
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
163 g_direct_hash, g_direct_equal,
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
164 NULL, free_auto_recon);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
165
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
166 purple_signal_connect(purple_accounts_get_handle(), "account-removed",
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
167 finch_connection_get_handle(),
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
168 PURPLE_CALLBACK(account_removed_cb), NULL);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
169 }
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 void finch_connections_uninit()
17346
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
172 {
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
173 purple_signals_disconnect_by_handle(finch_connection_get_handle());
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
174 g_hash_table_destroy(hash);
8c3a3407af58 Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents: 17091
diff changeset
175 }