Mercurial > pidgin
annotate src/gtkconn.c @ 11619:de413ae71cba
[gaim-migrate @ 13893]
This makes left and right tabs behave more like what we discussed.
Then I went mad and added two new tab placement options. We may
decide they completely suck and remove them, but they're kind of neat
so I thought i'd at least try.
I Broke some of the instant apply stuff. You WILL have to drag the tabs
into a new window to see them fully correctly. Basicly some stuff
will instant apply and some what. I need to fix this. Or you can
submit a patch :)
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Thu, 06 Oct 2005 02:13:39 +0000 |
parents | a9c4e139645f |
children | 3a05b53a589e |
rev | line source |
---|---|
5717 | 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 | 5 * gaim |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
5717 | 10 * |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
9791 | 25 #include "internal.h" |
26 #include "gtkgaim.h" | |
5717 | 27 |
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 | 31 #include "prefs.h" |
10643 | 32 #include "gtkblist.h" |
33 #include "gtkstatusbox.h" | |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10211
diff
changeset
|
34 #include "gtkstock.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
35 #include "util.h" |
5717 | 36 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
37 #include "gtkblist.h" |
9730 | 38 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
39 #include "gtkutils.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
40 |
11523 | 41 #define INITIAL_RECON_DELAY 8000 |
42 #define MAX_RECON_DELAY 2048000 | |
43 | |
44 typedef struct { | |
45 int delay; | |
46 guint timeout; | |
47 } GaimAutoRecon; | |
48 | |
49 static GHashTable *hash = NULL; | |
50 static GSList *accountReconnecting = NULL; | |
51 | |
5717 | 52 static void gaim_gtk_connection_connect_progress(GaimConnection *gc, |
53 const char *text, size_t step, size_t step_count) | |
54 { | |
10643 | 55 GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
56 if (!gtkblist) | |
57 return; | |
58 gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox), | |
59 (gaim_connections_get_connecting() != NULL)); | |
60 gtk_gaim_status_box_pulse_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox)); | |
5717 | 61 } |
62 | |
63 static void gaim_gtk_connection_connected(GaimConnection *gc) | |
64 { | |
10643 | 65 GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
11523 | 66 GaimAccount *account = NULL; |
10643 | 67 if (!gtkblist) |
68 return; | |
69 gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox), | |
70 (gaim_connections_get_connecting() != NULL)); | |
11523 | 71 account = gaim_connection_get_account(gc); |
11536 | 72 if (hash != NULL) |
73 g_hash_table_remove(hash, account); | |
11523 | 74 if (accountReconnecting == NULL) |
75 return; | |
76 accountReconnecting = g_slist_remove(accountReconnecting, account); | |
77 if (accountReconnecting == NULL) | |
78 gtk_gaim_status_box_set_error(GTK_GAIM_STATUS_BOX(gtkblist->statusbox), NULL); | |
5936
1b56a833d665
[gaim-migrate @ 6376]
Christian Hammond <chipx86@chipx86.com>
parents:
5885
diff
changeset
|
79 gaim_gtk_blist_update_protocol_actions(); |
5717 | 80 } |
81 | |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
82 static void gaim_gtk_connection_disconnected(GaimConnection *gc) |
5717 | 83 { |
10643 | 84 GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
85 if (!gtkblist) | |
86 return; | |
87 gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox), | |
88 (gaim_connections_get_connecting() != NULL)); | |
5936
1b56a833d665
[gaim-migrate @ 6376]
Christian Hammond <chipx86@chipx86.com>
parents:
5885
diff
changeset
|
89 gaim_gtk_blist_update_protocol_actions(); |
5883
f5b0c6073264
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
90 |
f5b0c6073264
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
91 if (gaim_connections_get_all() != NULL) |
f5b0c6073264
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
92 return; |
f5b0c6073264
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
93 |
9730 | 94 gaim_gtkdialogs_destroy_all(); |
5717 | 95 } |
96 | |
97 static void gaim_gtk_connection_notice(GaimConnection *gc, | |
98 const char *text) | |
99 { | |
100 } | |
101 | |
7912 | 102 |
11523 | 103 static void |
104 free_auto_recon(gpointer data) | |
7493 | 105 { |
11523 | 106 GaimAutoRecon *info = data; |
7912 | 107 |
11523 | 108 if (info->timeout != 0) |
109 g_source_remove(info->timeout); | |
7912 | 110 |
11523 | 111 g_free(info); |
7493 | 112 } |
113 | |
11523 | 114 static gboolean |
115 do_signon(gpointer data) | |
7912 | 116 { |
11523 | 117 GaimAccount *account = data; |
118 GaimAutoRecon *info; | |
10916 | 119 |
11523 | 120 gaim_debug(GAIM_DEBUG_INFO, "autorecon", "do_signon called\n"); |
121 g_return_val_if_fail(account != NULL, FALSE); | |
122 info = g_hash_table_lookup(hash, account); | |
7912 | 123 |
11523 | 124 if (g_list_index(gaim_accounts_get_all(), account) < 0) |
125 return FALSE; | |
126 | |
127 if (info) | |
128 info->timeout = 0; | |
7912 | 129 |
11523 | 130 gaim_debug(GAIM_DEBUG_INFO, "autorecon", "calling gaim_account_connect\n"); |
131 gaim_account_connect(account); | |
132 gaim_debug(GAIM_DEBUG_INFO, "autorecon", "done calling gaim_account_connect\n"); | |
7912 | 133 |
11523 | 134 return FALSE; |
7912 | 135 } |
136 | |
11523 | 137 static void gaim_gtk_connection_report_disconnect(GaimConnection *gc, const char *text) |
7399 | 138 { |
11523 | 139 GaimGtkBuddyList *list = gaim_gtk_blist_get_default_gtk_blist(); |
7431 | 140 GaimAccount *account = NULL; |
11523 | 141 GaimAutoRecon *info; |
142 GSList* listAccount; | |
7808 | 143 |
11523 | 144 if (hash == NULL) { |
145 hash = g_hash_table_new_full(g_int_hash, g_int_equal, NULL, | |
146 free_auto_recon); | |
147 } | |
148 account = gaim_connection_get_account(gc); | |
149 info = g_hash_table_lookup(hash, account); | |
150 if (accountReconnecting) | |
151 listAccount = g_slist_find(accountReconnecting, account); | |
152 else | |
153 listAccount = NULL; | |
7912 | 154 |
11523 | 155 if (!gc->wants_to_die) { |
11560 | 156 gtk_gaim_status_box_set_error(GTK_GAIM_STATUS_BOX(list->statusbox), text); |
157 | |
158 if (info == NULL) { | |
11523 | 159 info = g_new0(GaimAutoRecon, 1); |
160 g_hash_table_insert(hash, account, info); | |
161 info->delay = INITIAL_RECON_DELAY; | |
7483 | 162 } else { |
11523 | 163 info->delay = MIN(2 * info->delay, MAX_RECON_DELAY); |
164 if (info->timeout != 0) | |
165 g_source_remove(info->timeout); | |
7483 | 166 } |
11523 | 167 info->timeout = g_timeout_add(info->delay, do_signon, account); |
7912 | 168 |
11523 | 169 if (!listAccount) |
170 accountReconnecting = g_slist_prepend(accountReconnecting, account); | |
11559 | 171 } else { |
172 char *p, *s, *n=NULL ; | |
173 if (info != NULL) | |
174 g_hash_table_remove(hash, account); | |
175 | |
176 if (listAccount) | |
177 accountReconnecting = g_slist_delete_link(accountReconnecting, listAccount); | |
178 | |
179 if (gaim_account_get_alias(account)) { | |
180 n = g_strdup_printf("%s (%s) (%s)", | |
181 gaim_account_get_username(account), | |
182 gaim_account_get_alias(account), | |
183 gaim_account_get_protocol_name(account)); | |
184 } else { | |
185 n = g_strdup_printf("%s (%s)", | |
186 gaim_account_get_username(account), | |
187 gaim_account_get_protocol_name(account)); | |
188 } | |
11574
a9c4e139645f
[gaim-migrate @ 13843]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11560
diff
changeset
|
189 |
11559 | 190 p = g_strdup_printf(_("%s could not connect"), n); |
11574
a9c4e139645f
[gaim-migrate @ 13843]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11560
diff
changeset
|
191 s = g_strdup_printf(_("%s was unable to connect due to an error. %s The account has been disabled. " |
11559 | 192 "Correct the error and reenable to account to connect."), n, text); |
193 gaim_notify_error(NULL, NULL, p, s); | |
194 g_free(p); | |
195 g_free(s); | |
196 g_free(n); | |
197 gaim_account_set_enabled(account, GAIM_GTK_UI, FALSE); | |
7399 | 198 } |
199 } | |
200 | |
5717 | 201 static GaimConnectionUiOps conn_ui_ops = |
202 { | |
203 gaim_gtk_connection_connect_progress, | |
204 gaim_gtk_connection_connected, | |
205 gaim_gtk_connection_disconnected, | |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
206 gaim_gtk_connection_notice, |
11523 | 207 gaim_gtk_connection_report_disconnect, |
5717 | 208 }; |
209 | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6460
diff
changeset
|
210 GaimConnectionUiOps * |
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6460
diff
changeset
|
211 gaim_gtk_connections_get_ui_ops(void) |
5717 | 212 { |
213 return &conn_ui_ops; | |
214 } |