annotate src/gtkconn.c @ 13700:85267a333422

[gaim-migrate @ 16103] Added some translation comments, as discussed on gaim-i18. I wasn't really sure how to write these, but it's hopefully a step in the right direction... committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Fri, 28 Apr 2006 06:46:29 +0000
parents 6818e4fc3616
children 2eea3265dbe6
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;
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
54 static GHashTable *errored_accounts = NULL;
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
55
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
56 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
57 gaim_gtk_connection_connect_progress(GaimConnection *gc,
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
58 const char *text, size_t step, size_t step_count)
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
59 {
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
60 GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
61 if (!gtkblist)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
62 return;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
63 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
64 (gaim_connections_get_connecting() != NULL));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
65 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
66 }
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
67
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
68 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
69 gaim_gtk_connection_connected(GaimConnection *gc)
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
70 {
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
71 GaimAccount *account;
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
72 GaimGtkBuddyList *gtkblist;
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
73
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
74 account = gaim_connection_get_account(gc);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
75 gtkblist = gaim_gtk_blist_get_default_gtk_blist();
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
76
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
77 if (gtkblist != NULL)
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
78 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
79 (gaim_connections_get_connecting() != NULL));
12607
78048f8af66f [gaim-migrate @ 14943]
Mark Doliner <mark@kingant.net>
parents: 12583
diff changeset
80
11536
16796e09b9c1 [gaim-migrate @ 13790]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11523
diff changeset
81 if (hash != NULL)
16796e09b9c1 [gaim-migrate @ 13790]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11523
diff changeset
82 g_hash_table_remove(hash, account);
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
83
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
84 if (g_hash_table_size(errored_accounts) > 0)
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
85 {
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
86 g_hash_table_remove(errored_accounts, account);
13015
2d71d4081e06 [gaim-migrate @ 15368]
Mark Doliner <mark@kingant.net>
parents: 13014
diff changeset
87 gaim_gtk_blist_update_account_error_state(account, NULL);
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
88 }
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
89 }
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
90
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
91 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
92 gaim_gtk_connection_disconnected(GaimConnection *gc)
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
93 {
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
94 GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
95 if (!gtkblist)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
96 return;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents: 10504
diff changeset
97 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
98 (gaim_connections_get_connecting() != NULL));
5883
f5b0c6073264 [gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
99
f5b0c6073264 [gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
100 if (gaim_connections_get_all() != NULL)
f5b0c6073264 [gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
101 return;
f5b0c6073264 [gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
102
9730
c9ac1976ef01 [gaim-migrate @ 10591]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
103 gaim_gtkdialogs_destroy_all();
5717
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
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
106 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
107 gaim_gtk_connection_notice(GaimConnection *gc,
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
108 const char *text)
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
109 {
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
110 }
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
111
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 static void
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
114 free_auto_recon(gpointer data)
7493
6b9f452e84e1 [gaim-migrate @ 8106]
Mark Doliner <mark@kingant.net>
parents: 7483
diff changeset
115 {
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
116 GaimAutoRecon *info = data;
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 if (info->timeout != 0)
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
119 g_source_remove(info->timeout);
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
120
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
121 g_free(info);
7493
6b9f452e84e1 [gaim-migrate @ 8106]
Mark Doliner <mark@kingant.net>
parents: 7483
diff changeset
122 }
6b9f452e84e1 [gaim-migrate @ 8106]
Mark Doliner <mark@kingant.net>
parents: 7483
diff changeset
123
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
124 static gboolean
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
125 do_signon(gpointer data)
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
126 {
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
127 GaimAccount *account = data;
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
128 GaimAutoRecon *info;
13374
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
129 GaimStatus *status;
10916
e52ec3cffff4 [gaim-migrate @ 12675]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10915
diff changeset
130
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
131 gaim_debug_info("autorecon", "do_signon called\n");
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
132 g_return_val_if_fail(account != NULL, FALSE);
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
133 info = g_hash_table_lookup(hash, account);
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
134
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
135 if (info)
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
136 info->timeout = 0;
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
137
13374
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
138 status = gaim_account_get_active_status(account);
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
139 if (gaim_status_is_online(status))
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
140 {
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
141 gaim_debug_info("autorecon", "calling gaim_account_connect\n");
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
142 gaim_account_connect(account);
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
143 gaim_debug_info("autorecon", "done calling gaim_account_connect\n");
14d1892e0932 [gaim-migrate @ 15747]
Mark Doliner <mark@kingant.net>
parents: 13128
diff changeset
144 }
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
145
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
146 return FALSE;
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
147 }
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
148
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
149 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
150 gaim_gtk_connection_report_disconnect(GaimConnection *gc, const char *text)
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
151 {
7431
643cbc9a6035 [gaim-migrate @ 8036]
Sean Egan <seanegan@gmail.com>
parents: 7409
diff changeset
152 GaimAccount *account = NULL;
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
153 GaimAutoRecon *info;
13013
8fe78402c010 [gaim-migrate @ 15366]
Mark Doliner <mark@kingant.net>
parents: 12607
diff changeset
154 GSList* errored_account;
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7678
diff changeset
155
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
156 account = gaim_connection_get_account(gc);
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
157 info = g_hash_table_lookup(hash, account);
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
158 errored_account = g_hash_table_lookup(errored_accounts, account);
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
159
13031
6728a282269b [gaim-migrate @ 15384]
Mark Doliner <mark@kingant.net>
parents: 13015
diff changeset
160 gaim_gtk_blist_update_account_error_state(account, text);
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
161 if (!gc->wants_to_die) {
12009
8a7553e149de [gaim-migrate @ 14302]
Mark Doliner <mark@kingant.net>
parents: 11721
diff changeset
162 if (info == NULL) {
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
163 info = g_new0(GaimAutoRecon, 1);
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
164 g_hash_table_insert(hash, account, info);
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
165 info->delay = INITIAL_RECON_DELAY;
7483
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
166 } else {
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
167 info->delay = MIN(2 * info->delay, MAX_RECON_DELAY);
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
168 if (info->timeout != 0)
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
169 g_source_remove(info->timeout);
7483
4a416ff9cb4f [gaim-migrate @ 8096]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
170 }
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
171 info->timeout = g_timeout_add(info->delay, do_signon, account);
7912
4d4438f6ddce [gaim-migrate @ 8573]
Mark Doliner <mark@kingant.net>
parents: 7890
diff changeset
172
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
173 g_hash_table_insert(errored_accounts, account, NULL);
11559
5909ea4e7746 [gaim-migrate @ 13823]
Sean Egan <seanegan@gmail.com>
parents: 11536
diff changeset
174 } else {
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
175 char *p, *s, *n=NULL ;
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
176 if (info != NULL)
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
177 g_hash_table_remove(hash, account);
11721
2d98b2759fa1 [gaim-migrate @ 14012]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
178
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
179 if (errored_account != NULL)
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
180 g_hash_table_remove(errored_accounts, errored_account);
11721
2d98b2759fa1 [gaim-migrate @ 14012]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
181
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
182 if (gaim_account_get_alias(account))
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
183 {
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
184 n = g_strdup_printf("%s (%s) (%s)",
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
185 gaim_account_get_username(account),
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
186 gaim_account_get_alias(account),
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
187 gaim_account_get_protocol_name(account));
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
188 }
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
189 else
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
190 {
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
191 n = g_strdup_printf("%s (%s)",
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
192 gaim_account_get_username(account),
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
193 gaim_account_get_protocol_name(account));
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
194 }
11721
2d98b2759fa1 [gaim-migrate @ 14012]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
195
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
196 p = g_strdup_printf(_("%s disconnected"), n);
13128
8adf78fc630c [gaim-migrate @ 15490]
Mark Doliner <mark@kingant.net>
parents: 13122
diff changeset
197 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
198 "Gaim will not attempt to reconnect the account until you "
13541
6818e4fc3616 [gaim-migrate @ 15918]
Richard Laager <rlaager@wiktel.com>
parents: 13374
diff changeset
199 "correct the error and re-enable the account."), n, text);
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
200 gaim_notify_error(NULL, NULL, p, s);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
201 g_free(p);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
202 g_free(s);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
203 g_free(n);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
204
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
205 /*
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
206 * 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
207 * disconnected by wants_to_die? This happens when you sign
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
208 * on from somewhere else, or when you enter an invalid password.
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
209 */
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
210 gaim_account_set_enabled(account, GAIM_GTK_UI, FALSE);
7399
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
211 }
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
212 }
9ab1987e5d8b [gaim-migrate @ 7995]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
213
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
214 static GaimConnectionUiOps conn_ui_ops =
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 gaim_gtk_connection_connect_progress,
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
217 gaim_gtk_connection_connected,
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
218 gaim_gtk_connection_disconnected,
6460
ff4551719cc7 [gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
219 gaim_gtk_connection_notice,
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11251
diff changeset
220 gaim_gtk_connection_report_disconnect,
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
221 };
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
222
7035
feb3d21a7794 [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6460
diff changeset
223 GaimConnectionUiOps *
feb3d21a7794 [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6460
diff changeset
224 gaim_gtk_connections_get_ui_ops(void)
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
225 {
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
226 return &conn_ui_ops;
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
227 }
13014
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 static void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
230 account_removed_cb(GaimAccount *account, gpointer user_data)
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 g_hash_table_remove(hash, account);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
233
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
234 if (g_hash_table_size(errored_accounts) > 0)
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
235 {
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
236 g_hash_table_remove(errored_accounts, account);
13015
2d71d4081e06 [gaim-migrate @ 15368]
Mark Doliner <mark@kingant.net>
parents: 13014
diff changeset
237 gaim_gtk_blist_update_account_error_state(account, NULL);
13014
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
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
241
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 * GTK+ connection glue
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
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
246 void *
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
247 gaim_gtk_connection_get_handle(void)
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 static int handle;
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 return &handle;
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
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
254 void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
255 gaim_gtk_connection_init(void)
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 hash = g_hash_table_new_full(
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
258 g_direct_hash, g_direct_equal,
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
259 NULL, free_auto_recon);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
260 errored_accounts = g_hash_table_new_full(
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
261 g_direct_hash, g_direct_equal,
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
262 NULL, NULL);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
263
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
264 gaim_signal_connect(gaim_accounts_get_handle(), "account-removed",
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
265 gaim_gtk_connection_get_handle(),
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
266 GAIM_CALLBACK(account_removed_cb), NULL);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
267 }
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
268
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
269 void
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
270 gaim_gtk_connection_uninit(void)
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
271 {
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
272 gaim_signals_disconnect_by_handle(gaim_gtk_connection_get_handle());
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
273
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
274 g_hash_table_destroy(hash);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
275 g_hash_table_destroy(errored_accounts);
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13013
diff changeset
276 }