Wed, 21 Dec 2005 18:43:39 +0000
[gaim-migrate @ 14935]
Jason LeBrun wrote to gaim-devel:
"I have found a small quirk in the way gdk_pixbuf_loader works. When you
are using it without signalling, the proper way to use it is to call
gdk_pixbuf_loader_close *before* calling gdk_pixbuf_loader_get_animation
or gdk_pixbuf_loader_get_pixbuf. The call to gdk_pixbuf_loader_close
signals that no more writes will be occuring.
In particular, this affects images that are less than 1k in size. If
gdk_pixbuf_loader_close is not called before _get_animation, the loader
will not return anything unless it has received more than 1k of data
(the file type sniffing buffer size) or it has been closed.
So, the proper order of calls for loaders in the gtk*.c code is:
gdk_pixbuf_loader_new();
gdk_pixbuf_loader_write();
gdk_pixbuf_loader_close();
gdk_pixbuf_loader_get_animation();"
I know we fixed a bug by changing this in one place. I've gone through and updated the rest.
| 5717 | 1 | /* |
|
10297
b36800725b7a
[gaim-migrate @ 11480]
Evan Schoenberg <evands@pidgin.im>
parents:
10211
diff
changeset
|
2 | * @file gtkconn.c GTK+ Connection API |
|
b36800725b7a
[gaim-migrate @ 11480]
Evan Schoenberg <evands@pidgin.im>
parents:
10211
diff
changeset
|
3 | * @ingroup gtkui |
|
b36800725b7a
[gaim-migrate @ 11480]
Evan Schoenberg <evands@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
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
29 | #include "debug.h" |
|
6460
fc288e7221ca
[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" |
|
12404
657afdf0f596
[gaim-migrate @ 14711]
Richard Laager <rlaager@pidgin.im>
parents:
12296
diff
changeset
|
33 | #include "gtkconn.h" |
|
657afdf0f596
[gaim-migrate @ 14711]
Richard Laager <rlaager@pidgin.im>
parents:
12296
diff
changeset
|
34 | #include "gtkdialogs.h" |
| 10643 | 35 | #include "gtkstatusbox.h" |
|
10297
b36800725b7a
[gaim-migrate @ 11480]
Evan Schoenberg <evands@pidgin.im>
parents:
10211
diff
changeset
|
36 | #include "gtkstock.h" |
|
12404
657afdf0f596
[gaim-migrate @ 14711]
Richard Laager <rlaager@pidgin.im>
parents:
12296
diff
changeset
|
37 | #include "gtkutils.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
38 | #include "util.h" |
| 5717 | 39 | |
| 11523 | 40 | #define INITIAL_RECON_DELAY 8000 |
|
11721
c74083492667
[gaim-migrate @ 14012]
Mark Doliner <markdoliner@pidgin.im>
parents:
11638
diff
changeset
|
41 | #define MAX_RECON_DELAY 600000 |
| 11523 | 42 | |
| 43 | typedef struct { | |
| 44 | int delay; | |
| 45 | guint timeout; | |
| 46 | } GaimAutoRecon; | |
| 47 | ||
| 48 | static GHashTable *hash = NULL; | |
| 49 | static GSList *accountReconnecting = NULL; | |
| 50 | ||
| 5717 | 51 | static void gaim_gtk_connection_connect_progress(GaimConnection *gc, |
| 52 | const char *text, size_t step, size_t step_count) | |
| 53 | { | |
| 10643 | 54 | GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
|
12228
448ba4f01ac6
[gaim-migrate @ 14530]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12009
diff
changeset
|
55 | GtkGaimStatusBox *box; |
| 10643 | 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(); |
|
12228
448ba4f01ac6
[gaim-migrate @ 14530]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12009
diff
changeset
|
66 | GtkGaimStatusBox *box; |
| 11523 | 67 | GaimAccount *account = NULL; |
| 10643 | 68 | if (!gtkblist) |
| 69 | return; | |
| 70 | gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox), | |
| 71 | (gaim_connections_get_connecting() != NULL)); | |
| 11523 | 72 | account = gaim_connection_get_account(gc); |
|
12228
448ba4f01ac6
[gaim-migrate @ 14530]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12009
diff
changeset
|
73 | |
|
11536
f24fb5c6d2d5
[gaim-migrate @ 13790]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11523
diff
changeset
|
74 | if (hash != NULL) |
|
f24fb5c6d2d5
[gaim-migrate @ 13790]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11523
diff
changeset
|
75 | g_hash_table_remove(hash, account); |
| 11523 | 76 | if (accountReconnecting == NULL) |
| 77 | return; | |
| 78 | accountReconnecting = g_slist_remove(accountReconnecting, account); | |
| 79 | if (accountReconnecting == NULL) | |
| 80 | gtk_gaim_status_box_set_error(GTK_GAIM_STATUS_BOX(gtkblist->statusbox), NULL); | |
| 5717 | 81 | } |
| 82 | ||
|
6460
fc288e7221ca
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
83 | static void gaim_gtk_connection_disconnected(GaimConnection *gc) |
| 5717 | 84 | { |
| 10643 | 85 | GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
| 86 | if (!gtkblist) | |
| 87 | return; | |
| 88 | gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox), | |
| 89 | (gaim_connections_get_connecting() != NULL)); | |
|
5883
290fe1d16e60
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
90 | |
|
290fe1d16e60
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
91 | if (gaim_connections_get_all() != NULL) |
|
290fe1d16e60
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
92 | return; |
|
290fe1d16e60
[gaim-migrate @ 6315]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
93 | |
|
9730
e59812364b8b
[gaim-migrate @ 10591]
Mark Doliner <markdoliner@pidgin.im>
parents:
9709
diff
changeset
|
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
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
102 | |
| 11523 | 103 | static void |
| 104 | free_auto_recon(gpointer data) | |
| 7493 | 105 | { |
| 11523 | 106 | GaimAutoRecon *info = data; |
|
7912
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
107 | |
| 11523 | 108 | if (info->timeout != 0) |
| 109 | g_source_remove(info->timeout); | |
|
7912
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
110 | |
| 11523 | 111 | g_free(info); |
| 7493 | 112 | } |
| 113 | ||
| 11523 | 114 | static gboolean |
| 115 | do_signon(gpointer data) | |
|
7912
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
116 | { |
| 11523 | 117 | GaimAccount *account = data; |
| 118 | GaimAutoRecon *info; | |
|
10916
3de20dd2dade
[gaim-migrate @ 12675]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10915
diff
changeset
|
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
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
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
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
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
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
133 | |
| 11523 | 134 | return FALSE; |
|
7912
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
135 | } |
|
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
136 | |
| 11523 | 137 | static void gaim_gtk_connection_report_disconnect(GaimConnection *gc, const char *text) |
| 7399 | 138 | { |
|
12009
06852325c88f
[gaim-migrate @ 14302]
Mark Doliner <markdoliner@pidgin.im>
parents:
11721
diff
changeset
|
139 | GaimGtkBuddyList *gtkblist = 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) { |
|
11721
c74083492667
[gaim-migrate @ 14012]
Mark Doliner <markdoliner@pidgin.im>
parents:
11638
diff
changeset
|
145 | hash = g_hash_table_new_full(g_int_hash, g_int_equal, NULL, |
|
c74083492667
[gaim-migrate @ 14012]
Mark Doliner <markdoliner@pidgin.im>
parents:
11638
diff
changeset
|
146 | free_auto_recon); |
| 11523 | 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
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
154 | |
| 11523 | 155 | if (!gc->wants_to_die) { |
|
12009
06852325c88f
[gaim-migrate @ 14302]
Mark Doliner <markdoliner@pidgin.im>
parents:
11721
diff
changeset
|
156 | if (gtkblist != NULL) |
|
06852325c88f
[gaim-migrate @ 14302]
Mark Doliner <markdoliner@pidgin.im>
parents:
11721
diff
changeset
|
157 | gtk_gaim_status_box_set_error(GTK_GAIM_STATUS_BOX(gtkblist->statusbox), text); |
| 12583 | 158 | |
|
12009
06852325c88f
[gaim-migrate @ 14302]
Mark Doliner <markdoliner@pidgin.im>
parents:
11721
diff
changeset
|
159 | if (info == NULL) { |
| 11523 | 160 | info = g_new0(GaimAutoRecon, 1); |
| 161 | g_hash_table_insert(hash, account, info); | |
| 162 | info->delay = INITIAL_RECON_DELAY; | |
|
7483
08237091e8a5
[gaim-migrate @ 8096]
Mark Doliner <markdoliner@pidgin.im>
parents:
7431
diff
changeset
|
163 | } else { |
| 11523 | 164 | info->delay = MIN(2 * info->delay, MAX_RECON_DELAY); |
| 165 | if (info->timeout != 0) | |
| 166 | g_source_remove(info->timeout); | |
|
7483
08237091e8a5
[gaim-migrate @ 8096]
Mark Doliner <markdoliner@pidgin.im>
parents:
7431
diff
changeset
|
167 | } |
| 11523 | 168 | info->timeout = g_timeout_add(info->delay, do_signon, account); |
|
7912
b8f84918e7c1
[gaim-migrate @ 8573]
Mark Doliner <markdoliner@pidgin.im>
parents:
7890
diff
changeset
|
169 | |
| 11523 | 170 | if (!listAccount) |
| 171 | accountReconnecting = g_slist_prepend(accountReconnecting, account); | |
| 11559 | 172 | } else { |
| 173 | char *p, *s, *n=NULL ; | |
|
11721
c74083492667
[gaim-migrate @ 14012]
Mark Doliner <markdoliner@pidgin.im>
parents:
11638
diff
changeset
|
174 | if (info != NULL) |
| 11559 | 175 | g_hash_table_remove(hash, account); |
|
11721
c74083492667
[gaim-migrate @ 14012]
Mark Doliner <markdoliner@pidgin.im>
parents:
11638
diff
changeset
|
176 | |
| 11559 | 177 | if (listAccount) |
| 178 | accountReconnecting = g_slist_delete_link(accountReconnecting, listAccount); | |
|
11721
c74083492667
[gaim-migrate @ 14012]
Mark Doliner <markdoliner@pidgin.im>
parents:
11638
diff
changeset
|
179 | |
| 11559 | 180 | if (gaim_account_get_alias(account)) { |
| 181 | n = g_strdup_printf("%s (%s) (%s)", | |
| 182 | gaim_account_get_username(account), | |
| 183 | gaim_account_get_alias(account), | |
| 184 | gaim_account_get_protocol_name(account)); | |
| 185 | } else { | |
| 186 | n = g_strdup_printf("%s (%s)", | |
| 187 | gaim_account_get_username(account), | |
| 188 | gaim_account_get_protocol_name(account)); | |
| 189 | } | |
|
11721
c74083492667
[gaim-migrate @ 14012]
Mark Doliner <markdoliner@pidgin.im>
parents:
11638
diff
changeset
|
190 | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11574
diff
changeset
|
191 | p = g_strdup_printf(_("%s disconnected"), n); |
|
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11574
diff
changeset
|
192 | s = g_strdup_printf(_("%s was disconnected due to an error. %s The account has been disabled. " |
|
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11574
diff
changeset
|
193 | "Correct the error and reenable the account to connect."), n, text); |
| 11559 | 194 | gaim_notify_error(NULL, NULL, p, s); |
| 195 | g_free(p); | |
| 196 | g_free(s); | |
| 197 | g_free(n); | |
|
11638
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11574
diff
changeset
|
198 | /* XXX: do we really want to disable the account when it's disconnected by wants_to_die? |
|
1821b40269a3
[gaim-migrate @ 13914]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11574
diff
changeset
|
199 | * This normally happens when you sign on from somewhere else. */ |
| 11559 | 200 | gaim_account_set_enabled(account, GAIM_GTK_UI, FALSE); |
| 7399 | 201 | } |
| 202 | } | |
| 203 | ||
| 5717 | 204 | static GaimConnectionUiOps conn_ui_ops = |
| 205 | { | |
| 206 | gaim_gtk_connection_connect_progress, | |
| 207 | gaim_gtk_connection_connected, | |
| 208 | gaim_gtk_connection_disconnected, | |
|
6460
fc288e7221ca
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
209 | gaim_gtk_connection_notice, |
| 11523 | 210 | gaim_gtk_connection_report_disconnect, |
| 5717 | 211 | }; |
| 212 | ||
|
7035
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6460
diff
changeset
|
213 | GaimConnectionUiOps * |
|
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6460
diff
changeset
|
214 | gaim_gtk_connections_get_ui_ops(void) |
| 5717 | 215 | { |
| 216 | return &conn_ui_ops; | |
| 217 | } |