annotate src/gtkconn.c @ 14133:31d33e7bc0e6

[gaim-migrate @ 16775] A global buddy icon selector in the statusbox. This is done totally in the GTK+ UI; the core still sees a buddy icon as belonging to an account. Per-account icons can override the global one in Modify Account. There are some caching issues to work out, still. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Tue, 15 Aug 2006 23:25:29 +0000
parents 87797e287549
children
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
13991
87797e287549 [gaim-migrate @ 16565]
Sean Egan <seanegan@gmail.com>
parents: 13754
diff changeset
40 #define INITIAL_RECON_DELAY_MIN 8000
87797e287549 [gaim-migrate @ 16565]
Sean Egan <seanegan@gmail.com>
parents: 13754
diff changeset
41 #define INITIAL_RECON_DELAY_MAX 60000
87797e287549 [gaim-migrate @ 16565]
Sean Egan <seanegan@gmail.com>
parents: 13754
diff changeset
42
11721
2d98b2759fa1 [gaim-migrate @ 14012]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
43 #define MAX_RECON_DELAY 600000
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
44
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
45 typedef struct {
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
46 int delay;
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
47 guint timeout;
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
48 } GaimAutoRecon;
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
49
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
50 /**
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
51 * Contains accounts that are auto-reconnecting.
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
52 * The key is a pointer to the GaimAccount and the
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
53 * value is a pointer to a GaimAutoRecon.
13013
8fe78402c010 [gaim-migrate @ 15366]
Mark Doliner <mark@kingant.net>
parents: 12607
diff changeset
54 */
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
55 static GHashTable *hash = NULL;
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
56
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
57 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
58 gaim_gtk_connection_connect_progress(GaimConnection *gc,
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
59 const char *text, size_t step, size_t step_count)
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
60 {
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
61 GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
62 if (!gtkblist)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
63 return;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
64 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
65 (gaim_connections_get_connecting() != NULL));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
66 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
67 }
13754
69e02f13b525 [gaim-migrate @ 16165]
Mark Doliner <mark@kingant.net>
parents: 13730
diff changeset
68
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
69 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
70 gaim_gtk_connection_connected(GaimConnection *gc)
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
71 {
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
72 GaimAccount *account;
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
73 GaimGtkBuddyList *gtkblist;
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
74
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
75 account = gaim_connection_get_account(gc);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
76 gtkblist = gaim_gtk_blist_get_default_gtk_blist();
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
77
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
78 if (gtkblist != NULL)
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
79 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
80 (gaim_connections_get_connecting() != NULL));
12607
78048f8af66f [gaim-migrate @ 14943]
Mark Doliner <mark@kingant.net>
parents: 12583
diff changeset
81
11536
16796e09b9c1 [gaim-migrate @ 13790]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11523
diff changeset
82 if (hash != NULL)
16796e09b9c1 [gaim-migrate @ 13790]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11523
diff changeset
83 g_hash_table_remove(hash, account);
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
84
13730
2eea3265dbe6 [gaim-migrate @ 16141]
Mark Doliner <mark@kingant.net>
parents: 13541
diff changeset
85 gaim_gtk_blist_update_account_error_state(account, NULL);
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
86 }
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
87
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
88 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
89 gaim_gtk_connection_disconnected(GaimConnection *gc)
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
90 {
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
91 GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
92 if (!gtkblist)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
93 return;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
94 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
95 (gaim_connections_get_connecting() != NULL));
5883
f5b0c6073264 [gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
96
f5b0c6073264 [gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
97 if (gaim_connections_get_all() != NULL)
f5b0c6073264 [gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
98 return;
f5b0c6073264 [gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
99
9730
c9ac1976ef01 [gaim-migrate @ 10591]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
100 gaim_gtkdialogs_destroy_all();
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
101 }
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
102
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
103 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
104 gaim_gtk_connection_notice(GaimConnection *gc,
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
105 const char *text)
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
106 {
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
107 }
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
108
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
109
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
110 static void
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
111 free_auto_recon(gpointer data)
7493
6b9f452e84e1 [gaim-migrate @ 8106]
Mark Doliner <mark@kingant.net>
parents: 7483
diff changeset
112 {
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
113 GaimAutoRecon *info = data;
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
114
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
115 if (info->timeout != 0)
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
116 g_source_remove(info->timeout);
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
117
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
118 g_free(info);
7493
6b9f452e84e1 [gaim-migrate @ 8106]
Mark Doliner <mark@kingant.net>
parents: 7483
diff changeset
119 }
6b9f452e84e1 [gaim-migrate @ 8106]
Mark Doliner <mark@kingant.net>
parents: 7483
diff changeset
120
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
121 static gboolean
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
122 do_signon(gpointer data)
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
123 {
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
124 GaimAccount *account = data;
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
125 GaimAutoRecon *info;
13374
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
126 GaimStatus *status;
10916
e52ec3cffff4 [gaim-migrate @ 12675]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10915
diff changeset
127
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
128 gaim_debug_info("autorecon", "do_signon called\n");
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
129 g_return_val_if_fail(account != NULL, FALSE);
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
130 info = g_hash_table_lookup(hash, account);
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
131
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
132 if (info)
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
133 info->timeout = 0;
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
134
13374
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
135 status = gaim_account_get_active_status(account);
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
136 if (gaim_status_is_online(status))
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
137 {
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
138 gaim_debug_info("autorecon", "calling gaim_account_connect\n");
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
139 gaim_account_connect(account);
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
140 gaim_debug_info("autorecon", "done calling gaim_account_connect\n");
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
141 }
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
142
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
143 return FALSE;
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
144 }
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
145
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
146 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
147 gaim_gtk_connection_report_disconnect(GaimConnection *gc, const char *text)
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
148 {
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7409
diff changeset
149 GaimAccount *account = NULL;
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
150 GaimAutoRecon *info;
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
151
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
152 account = gaim_connection_get_account(gc);
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
153 info = g_hash_table_lookup(hash, account);
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
154
13031
6728a282269b [gaim-migrate @ 15384]
Mark Doliner <mark@kingant.net>
parents: 13015
diff changeset
155 gaim_gtk_blist_update_account_error_state(account, text);
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
156 if (!gc->wants_to_die) {
12009
8a7553e149de [gaim-migrate @ 14302]
Mark Doliner <mark@kingant.net>
parents: 11721
diff changeset
157 if (info == NULL) {
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
158 info = g_new0(GaimAutoRecon, 1);
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
159 g_hash_table_insert(hash, account, info);
13991
87797e287549 [gaim-migrate @ 16565]
Sean Egan <seanegan@gmail.com>
parents: 13754
diff changeset
160 info->delay = g_random_int_range(INITIAL_RECON_DELAY_MIN, INITIAL_RECON_DELAY_MAX);
7483
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
161 } else {
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
162 info->delay = MIN(2 * info->delay, MAX_RECON_DELAY);
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
163 if (info->timeout != 0)
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
164 g_source_remove(info->timeout);
7483
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
165 }
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
166 info->timeout = g_timeout_add(info->delay, do_signon, account);
11559
5909ea4e7746 [gaim-migrate @ 13823]
Sean Egan <seanegan@gmail.com>
parents: 11536
diff changeset
167 } else {
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
168 char *p, *s, *n=NULL ;
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
169 if (info != NULL)
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
170 g_hash_table_remove(hash, account);
11721
2d98b2759fa1 [gaim-migrate @ 14012]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
171
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
172 if (gaim_account_get_alias(account))
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
173 {
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
174 n = g_strdup_printf("%s (%s) (%s)",
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
175 gaim_account_get_username(account),
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
176 gaim_account_get_alias(account),
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
177 gaim_account_get_protocol_name(account));
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 else
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
180 {
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
181 n = g_strdup_printf("%s (%s)",
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
182 gaim_account_get_username(account),
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
183 gaim_account_get_protocol_name(account));
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
184 }
11721
2d98b2759fa1 [gaim-migrate @ 14012]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
185
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
186 p = g_strdup_printf(_("%s disconnected"), n);
13128
8adf78fc630c [gaim-migrate @ 15490]
Mark Doliner <mark@kingant.net>
parents: 13122
diff changeset
187 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
188 "Gaim will not attempt to reconnect the account until you "
13541
6818e4fc3616 [gaim-migrate @ 15918]
Richard Laager <rlaager@wiktel.com>
parents: 13374
diff changeset
189 "correct the error and re-enable the account."), n, text);
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
190 gaim_notify_error(NULL, NULL, p, s);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
191 g_free(p);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
192 g_free(s);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
193 g_free(n);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
194
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
195 /*
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
196 * 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
197 * disconnected by wants_to_die? This happens when you sign
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
198 * on from somewhere else, or when you enter an invalid password.
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
199 */
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
200 gaim_account_set_enabled(account, GAIM_GTK_UI, FALSE);
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
201 }
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
202 }
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
203
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
204 static GaimConnectionUiOps conn_ui_ops =
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
205 {
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
206 gaim_gtk_connection_connect_progress,
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
207 gaim_gtk_connection_connected,
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
208 gaim_gtk_connection_disconnected,
6460
ff4551719cc7 [gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
209 gaim_gtk_connection_notice,
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
210 gaim_gtk_connection_report_disconnect,
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
211 };
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
212
7035
feb3d21a7794 [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6460
diff changeset
213 GaimConnectionUiOps *
feb3d21a7794 [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6460
diff changeset
214 gaim_gtk_connections_get_ui_ops(void)
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
215 {
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
216 return &conn_ui_ops;
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
217 }
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
218
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
219 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
220 account_removed_cb(GaimAccount *account, gpointer user_data)
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
221 {
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
222 g_hash_table_remove(hash, account);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
223
13730
2eea3265dbe6 [gaim-migrate @ 16141]
Mark Doliner <mark@kingant.net>
parents: 13541
diff changeset
224 gaim_gtk_blist_update_account_error_state(account, NULL);
13014
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
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 * GTK+ connection glue
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
230 **************************************************************************/
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
231
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
232 void *
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
233 gaim_gtk_connection_get_handle(void)
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 static int 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 return &handle;
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
238 }
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
239
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
240 void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
241 gaim_gtk_connection_init(void)
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
242 {
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
243 hash = g_hash_table_new_full(
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
244 g_direct_hash, g_direct_equal,
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
245 NULL, free_auto_recon);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
246
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
247 gaim_signal_connect(gaim_accounts_get_handle(), "account-removed",
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
248 gaim_gtk_connection_get_handle(),
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
249 GAIM_CALLBACK(account_removed_cb), NULL);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
250 }
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
251
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
252 void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
253 gaim_gtk_connection_uninit(void)
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 gaim_signals_disconnect_by_handle(gaim_gtk_connection_get_handle());
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
256
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
257 g_hash_table_destroy(hash);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
258 }