annotate src/gtkconn.c @ 13839:2bd34a419091

[gaim-migrate @ 16291] Nothing to see here, GAIM_CMD_P_VERY_LOW and GAIM_CMD_P_VERYHIGH just struck me wrong, so now it is GAIM_CMD_P_VERY_HIGH to match. Also fix a couple typos in the documentation for gaim_cmd_register. committer: Tailor Script <tailor@pidgin.im>
author Etan Reisner <pidgin@unreliablesource.net>
date Mon, 19 Jun 2006 14:17:34 +0000
parents 69e02f13b525
children 87797e287549
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
10297
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 10211
diff changeset
2 * @file gtkconn.c GTK+ Connection API
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 10211
diff changeset
3 * @ingroup gtkui
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 10211
diff changeset
4 *
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 * gaim
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
6 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 8014
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 8014
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 8014
diff changeset
9 * source distribution.
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 *
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * (at your option) any later version.
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 *
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 * GNU General Public License for more details.
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 *
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
24 */
9791
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 9730
diff changeset
25 #include "internal.h"
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 9730
diff changeset
26 #include "gtkgaim.h"
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
27
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
28 #include "account.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5746
diff changeset
29 #include "debug.h"
6460
ff4551719cc7 [gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
30 #include "notify.h"
6216
dc42b27101c0 [gaim-migrate @ 6702]
Nathan Walp <nwalp@pidgin.im>
parents: 6114
diff changeset
31 #include "prefs.h"
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
32 #include "gtkblist.h"
12404
7c7cb03e5475 [gaim-migrate @ 14711]
Richard Laager <rlaager@wiktel.com>
parents: 12296
diff changeset
33 #include "gtkconn.h"
7c7cb03e5475 [gaim-migrate @ 14711]
Richard Laager <rlaager@wiktel.com>
parents: 12296
diff changeset
34 #include "gtkdialogs.h"
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
35 #include "gtkstatusbox.h"
10297
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 10211
diff changeset
36 #include "gtkstock.h"
12404
7c7cb03e5475 [gaim-migrate @ 14711]
Richard Laager <rlaager@wiktel.com>
parents: 12296
diff changeset
37 #include "gtkutils.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5746
diff changeset
38 #include "util.h"
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
40 #define INITIAL_RECON_DELAY 8000
11721
2d98b2759fa1 [gaim-migrate @ 14012]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
41 #define MAX_RECON_DELAY 600000
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
42
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
43 typedef struct {
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
44 int delay;
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
45 guint timeout;
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
46 } GaimAutoRecon;
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
47
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
48 /**
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
49 * Contains accounts that are auto-reconnecting.
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
50 * The key is a pointer to the GaimAccount and the
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
51 * value is a pointer to a GaimAutoRecon.
13013
8fe78402c010 [gaim-migrate @ 15366]
Mark Doliner <mark@kingant.net>
parents: 12607
diff changeset
52 */
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
53 static GHashTable *hash = NULL;
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
54
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
55 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
56 gaim_gtk_connection_connect_progress(GaimConnection *gc,
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
57 const char *text, size_t step, size_t step_count)
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
58 {
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
59 GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
60 if (!gtkblist)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
61 return;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
62 gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox),
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
63 (gaim_connections_get_connecting() != NULL));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
64 gtk_gaim_status_box_pulse_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox));
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
65 }
13754
69e02f13b525 [gaim-migrate @ 16165]
Mark Doliner <mark@kingant.net>
parents: 13730
diff changeset
66
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
67 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
68 gaim_gtk_connection_connected(GaimConnection *gc)
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
69 {
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
70 GaimAccount *account;
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
71 GaimGtkBuddyList *gtkblist;
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
72
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
73 account = gaim_connection_get_account(gc);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
74 gtkblist = gaim_gtk_blist_get_default_gtk_blist();
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
75
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
76 if (gtkblist != NULL)
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
77 gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox),
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
78 (gaim_connections_get_connecting() != NULL));
12607
78048f8af66f [gaim-migrate @ 14943]
Mark Doliner <mark@kingant.net>
parents: 12583
diff changeset
79
11536
16796e09b9c1 [gaim-migrate @ 13790]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11523
diff changeset
80 if (hash != NULL)
16796e09b9c1 [gaim-migrate @ 13790]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11523
diff changeset
81 g_hash_table_remove(hash, account);
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
82
13730
2eea3265dbe6 [gaim-migrate @ 16141]
Mark Doliner <mark@kingant.net>
parents: 13541
diff changeset
83 gaim_gtk_blist_update_account_error_state(account, NULL);
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
84 }
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
85
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
86 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
87 gaim_gtk_connection_disconnected(GaimConnection *gc)
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
88 {
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
89 GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
90 if (!gtkblist)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
91 return;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
92 gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox),
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
93 (gaim_connections_get_connecting() != NULL));
5883
f5b0c6073264 [gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
94
f5b0c6073264 [gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
95 if (gaim_connections_get_all() != NULL)
f5b0c6073264 [gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
96 return;
f5b0c6073264 [gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
97
9730
c9ac1976ef01 [gaim-migrate @ 10591]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
98 gaim_gtkdialogs_destroy_all();
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
99 }
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
100
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
101 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
102 gaim_gtk_connection_notice(GaimConnection *gc,
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
103 const char *text)
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
104 {
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
105 }
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
106
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
107
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
108 static void
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
109 free_auto_recon(gpointer data)
7493
6b9f452e84e1 [gaim-migrate @ 8106]
Mark Doliner <mark@kingant.net>
parents: 7483
diff changeset
110 {
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
111 GaimAutoRecon *info = data;
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
112
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
113 if (info->timeout != 0)
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
114 g_source_remove(info->timeout);
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
115
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
116 g_free(info);
7493
6b9f452e84e1 [gaim-migrate @ 8106]
Mark Doliner <mark@kingant.net>
parents: 7483
diff changeset
117 }
6b9f452e84e1 [gaim-migrate @ 8106]
Mark Doliner <mark@kingant.net>
parents: 7483
diff changeset
118
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
119 static gboolean
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
120 do_signon(gpointer data)
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
121 {
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
122 GaimAccount *account = data;
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
123 GaimAutoRecon *info;
13374
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
124 GaimStatus *status;
10916
e52ec3cffff4 [gaim-migrate @ 12675]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10915
diff changeset
125
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
126 gaim_debug_info("autorecon", "do_signon called\n");
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
127 g_return_val_if_fail(account != NULL, FALSE);
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
128 info = g_hash_table_lookup(hash, account);
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
129
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
130 if (info)
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
131 info->timeout = 0;
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
132
13374
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
133 status = gaim_account_get_active_status(account);
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
134 if (gaim_status_is_online(status))
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
135 {
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
136 gaim_debug_info("autorecon", "calling gaim_account_connect\n");
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
137 gaim_account_connect(account);
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
138 gaim_debug_info("autorecon", "done calling gaim_account_connect\n");
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
139 }
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
140
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
141 return FALSE;
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
142 }
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
143
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
144 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
145 gaim_gtk_connection_report_disconnect(GaimConnection *gc, const char *text)
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
146 {
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7409
diff changeset
147 GaimAccount *account = NULL;
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
148 GaimAutoRecon *info;
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
149
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
150 account = gaim_connection_get_account(gc);
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
151 info = g_hash_table_lookup(hash, account);
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
152
13031
6728a282269b [gaim-migrate @ 15384]
Mark Doliner <mark@kingant.net>
parents: 13015
diff changeset
153 gaim_gtk_blist_update_account_error_state(account, text);
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
154 if (!gc->wants_to_die) {
12009
8a7553e149de [gaim-migrate @ 14302]
Mark Doliner <mark@kingant.net>
parents: 11721
diff changeset
155 if (info == NULL) {
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
156 info = g_new0(GaimAutoRecon, 1);
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
157 g_hash_table_insert(hash, account, info);
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
158 info->delay = INITIAL_RECON_DELAY;
7483
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
159 } else {
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
160 info->delay = MIN(2 * info->delay, MAX_RECON_DELAY);
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
161 if (info->timeout != 0)
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
162 g_source_remove(info->timeout);
7483
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
163 }
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
164 info->timeout = g_timeout_add(info->delay, do_signon, account);
11559
5909ea4e7746 [gaim-migrate @ 13823]
Sean Egan <seanegan@gmail.com>
parents: 11536
diff changeset
165 } else {
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
166 char *p, *s, *n=NULL ;
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
167 if (info != NULL)
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
168 g_hash_table_remove(hash, account);
11721
2d98b2759fa1 [gaim-migrate @ 14012]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
169
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
170 if (gaim_account_get_alias(account))
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
171 {
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
172 n = g_strdup_printf("%s (%s) (%s)",
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
173 gaim_account_get_username(account),
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
174 gaim_account_get_alias(account),
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
175 gaim_account_get_protocol_name(account));
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
176 }
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
177 else
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
178 {
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
179 n = g_strdup_printf("%s (%s)",
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
180 gaim_account_get_username(account),
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
181 gaim_account_get_protocol_name(account));
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
182 }
11721
2d98b2759fa1 [gaim-migrate @ 14012]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
183
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
184 p = g_strdup_printf(_("%s disconnected"), n);
13128
8adf78fc630c [gaim-migrate @ 15490]
Mark Doliner <mark@kingant.net>
parents: 13122
diff changeset
185 s = g_strdup_printf(_("%s was disconnected due to an error: %s\n"
8adf78fc630c [gaim-migrate @ 15490]
Mark Doliner <mark@kingant.net>
parents: 13122
diff changeset
186 "Gaim will not attempt to reconnect the account until you "
13541
6818e4fc3616 [gaim-migrate @ 15918]
Richard Laager <rlaager@wiktel.com>
parents: 13374
diff changeset
187 "correct the error and re-enable the account."), n, text);
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
188 gaim_notify_error(NULL, NULL, p, s);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
189 g_free(p);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
190 g_free(s);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
191 g_free(n);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
192
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
193 /*
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
194 * TODO: Do we really want to disable the account when it's
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
195 * disconnected by wants_to_die? This happens when you sign
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
196 * on from somewhere else, or when you enter an invalid password.
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
197 */
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
198 gaim_account_set_enabled(account, GAIM_GTK_UI, FALSE);
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
199 }
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
200 }
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
201
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
202 static GaimConnectionUiOps conn_ui_ops =
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
203 {
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
204 gaim_gtk_connection_connect_progress,
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
205 gaim_gtk_connection_connected,
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
206 gaim_gtk_connection_disconnected,
6460
ff4551719cc7 [gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
207 gaim_gtk_connection_notice,
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
208 gaim_gtk_connection_report_disconnect,
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
209 };
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
210
7035
feb3d21a7794 [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6460
diff changeset
211 GaimConnectionUiOps *
feb3d21a7794 [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6460
diff changeset
212 gaim_gtk_connections_get_ui_ops(void)
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
213 {
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
214 return &conn_ui_ops;
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
215 }
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
216
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
217 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
218 account_removed_cb(GaimAccount *account, gpointer user_data)
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
219 {
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
220 g_hash_table_remove(hash, account);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
221
13730
2eea3265dbe6 [gaim-migrate @ 16141]
Mark Doliner <mark@kingant.net>
parents: 13541
diff changeset
222 gaim_gtk_blist_update_account_error_state(account, NULL);
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
223 }
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
224
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
225
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
226 /**************************************************************************
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
227 * GTK+ connection glue
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
228 **************************************************************************/
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
229
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
230 void *
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
231 gaim_gtk_connection_get_handle(void)
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
232 {
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
233 static int handle;
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
234
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
235 return &handle;
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
236 }
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
237
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
238 void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
239 gaim_gtk_connection_init(void)
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
240 {
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
241 hash = g_hash_table_new_full(
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
242 g_direct_hash, g_direct_equal,
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
243 NULL, free_auto_recon);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
244
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
245 gaim_signal_connect(gaim_accounts_get_handle(), "account-removed",
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
246 gaim_gtk_connection_get_handle(),
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
247 GAIM_CALLBACK(account_removed_cb), NULL);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
248 }
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
249
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
250 void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
251 gaim_gtk_connection_uninit(void)
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
252 {
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
253 gaim_signals_disconnect_by_handle(gaim_gtk_connection_get_handle());
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
254
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
255 g_hash_table_destroy(hash);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
256 }