Mercurial > pidgin.yaz
annotate libpurple/buddyicon.c @ 25641:42a4331acb82
Patch from Michael Ruprecht (Maiku) to announce voice support to the officia gtalk client. References #34.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 22 Mar 2008 05:09:19 +0000 |
parents | 9a12b7f5b1f5 |
children | 76af23621e19 |
rev | line source |
---|---|
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2 * @file icon.c Buddy Icon API |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * @ingroup core |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
4 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
5 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
6 /* purple |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
15823 | 8 * Purple is the legal property of its developers, whose names are too numerous |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * to list here. Please refer to the COPYRIGHT file distributed with this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * source distribution. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 * along with this program; if not, write to the Free Software |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18063
diff
changeset
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 #include "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 #include "buddyicon.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 #include "conversation.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #include "dbus-maybe.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #include "debug.h" |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
31 #include "imgstore.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include "util.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
34 typedef struct _PurpleBuddyIconData PurpleBuddyIconData; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
35 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
36 /* NOTE: Instances of this struct are allocated without zeroing the memory, so |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
37 * NOTE: be sure to update purple_buddy_icon_new() if you add members. */ |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
38 struct _PurpleBuddyIcon |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
39 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
40 PurpleAccount *account; /**< The account the user is on. */ |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
41 PurpleStoredImage *img; /**< The id of the stored image with the |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
42 the icon data. */ |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
43 char *username; /**< The username the icon belongs to. */ |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
44 char *checksum; /**< The protocol checksum. */ |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
45 int ref_count; /**< The buddy icon reference count. */ |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
46 }; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
47 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 static GHashTable *account_cache = NULL; |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
49 static GHashTable *icon_data_cache = NULL; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
50 static GHashTable *icon_file_cache = NULL; |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
51 |
22027 | 52 static void delete_buddy_icon_settings(PurpleBlistNode *node, const char *setting_name); |
53 | |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
54 /* This one is used for both custom buddy icons |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
55 * on PurpleContacts and account icons. */ |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
56 static GHashTable *pointer_icon_cache = NULL; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
57 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 static char *cache_dir = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 static gboolean icon_caching = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
61 /* For ~/.gaim to ~/.purple migration. */ |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
62 static char *old_icons_dir = NULL; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
63 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
64 static void |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
65 ref_filename(const char *filename) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
66 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
67 int refs; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
68 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
69 g_return_if_fail(filename != NULL); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
70 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
71 refs = GPOINTER_TO_INT(g_hash_table_lookup(icon_file_cache, filename)); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
72 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
73 g_hash_table_insert(icon_file_cache, g_strdup(filename), |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
74 GINT_TO_POINTER(refs + 1)); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
75 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
76 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
77 static void |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
78 unref_filename(const char *filename) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
79 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
80 int refs; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
81 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
82 if (filename == NULL) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
83 return; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
84 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
85 refs = GPOINTER_TO_INT(g_hash_table_lookup(icon_file_cache, filename)); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
86 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
87 if (refs == 1) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
88 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
89 g_hash_table_remove(icon_file_cache, filename); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
90 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
91 else |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
92 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
93 g_hash_table_insert(icon_file_cache, g_strdup(filename), |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
94 GINT_TO_POINTER(refs - 1)); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
95 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
96 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
97 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
98 static void |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
99 purple_buddy_icon_data_cache(PurpleStoredImage *img) |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
100 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
101 const char *dirname; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
102 char *path; |
21843
a3bc0682e98d
Patch from eperez to make writing to buddy icon files atomic. Fixes #3528.
Sean Egan <seanegan@gmail.com>
parents:
21588
diff
changeset
|
103 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
104 g_return_if_fail(img != NULL); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
105 |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
106 if (!purple_buddy_icons_is_caching()) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
107 return; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
108 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
109 dirname = purple_buddy_icons_get_cache_dir(); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
110 path = g_build_filename(dirname, purple_imgstore_get_filename(img), NULL); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
111 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
112 if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
113 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
114 purple_debug_info("buddyicon", "Creating icon cache directory.\n"); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
115 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
116 if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
117 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
118 purple_debug_error("buddyicon", |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
119 "Unable to create directory %s: %s\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20350
diff
changeset
|
120 dirname, g_strerror(errno)); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
121 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
122 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
123 |
22405
9a12b7f5b1f5
Just write out the buddy icon file; there's no need to check to see if it exists. This is for the cache, and if the blist.xml gets out of sync with the cache on disk (for example, because the user moves the blist.xml file out of the way), the existing code will never update the cached icon again.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22401
diff
changeset
|
124 purple_util_write_data_to_file_absolute(path, purple_imgstore_get_data(img), |
9a12b7f5b1f5
Just write out the buddy icon file; there's no need to check to see if it exists. This is for the cache, and if the blist.xml gets out of sync with the cache on disk (for example, because the user moves the blist.xml file out of the way), the existing code will never update the cached icon again.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22401
diff
changeset
|
125 purple_imgstore_get_size(img)); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
126 g_free(path); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
127 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
128 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
129 static void |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
130 purple_buddy_icon_data_uncache_file(const char *filename) |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
131 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
132 const char *dirname; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
133 char *path; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
134 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
135 g_return_if_fail(filename != NULL); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
136 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
137 /* It's possible that there are other references to this icon |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
138 * cache file that are not currently loaded into memory. */ |
16376
dd47fa8ba3e4
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@wiktel.com>
parents:
16375
diff
changeset
|
139 if (GPOINTER_TO_INT(g_hash_table_lookup(icon_file_cache, filename))) |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
140 return; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
141 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
142 dirname = purple_buddy_icons_get_cache_dir(); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
143 path = g_build_filename(dirname, filename, NULL); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
144 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
145 if (g_file_test(path, G_FILE_TEST_EXISTS)) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
146 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
147 if (g_unlink(path)) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
148 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
149 purple_debug_error("buddyicon", "Failed to delete %s: %s\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20350
diff
changeset
|
150 path, g_strerror(errno)); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
151 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
152 else |
16376
dd47fa8ba3e4
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@wiktel.com>
parents:
16375
diff
changeset
|
153 { |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
154 purple_debug_info("buddyicon", "Deleted cache file: %s\n", path); |
16376
dd47fa8ba3e4
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@wiktel.com>
parents:
16375
diff
changeset
|
155 } |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
156 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
157 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
158 g_free(path); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
159 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
160 |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
161 static gboolean |
16383
05033ae856b2
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
162 value_equals(gpointer key, gpointer value, gpointer user_data) |
05033ae856b2
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
163 { |
05033ae856b2
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
164 return (value == user_data); |
05033ae856b2
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
165 } |
05033ae856b2
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
166 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
167 static void |
16688
61ddeb85ab86
Document the image-deleting signal.
Richard Laager <rlaager@wiktel.com>
parents:
16667
diff
changeset
|
168 image_deleting_cb(const PurpleStoredImage *img, gpointer data) |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
169 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
170 const char *filename = purple_imgstore_get_filename(img); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
171 |
16628
36981d83b20c
Fix a crash when removing a per-account icon. Here's my explanation:
Richard Laager <rlaager@wiktel.com>
parents:
16622
diff
changeset
|
172 /* If there's no filename, it can't be one of our images. */ |
36981d83b20c
Fix a crash when removing a per-account icon. Here's my explanation:
Richard Laager <rlaager@wiktel.com>
parents:
16622
diff
changeset
|
173 if (filename == NULL) |
36981d83b20c
Fix a crash when removing a per-account icon. Here's my explanation:
Richard Laager <rlaager@wiktel.com>
parents:
16622
diff
changeset
|
174 return; |
36981d83b20c
Fix a crash when removing a per-account icon. Here's my explanation:
Richard Laager <rlaager@wiktel.com>
parents:
16622
diff
changeset
|
175 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
176 if (img == g_hash_table_lookup(icon_data_cache, filename)) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
177 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
178 purple_buddy_icon_data_uncache_file(filename); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
179 g_hash_table_remove(icon_data_cache, filename); |
16383
05033ae856b2
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
180 |
05033ae856b2
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
181 /* We could make this O(1) by using another hash table, but |
05033ae856b2
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
182 * this is probably good enough. */ |
16710
77cfd9bd6536
Get rid of two harmless warnings:
Mark Doliner <mark@kingant.net>
parents:
16688
diff
changeset
|
183 g_hash_table_foreach_remove(pointer_icon_cache, value_equals, (gpointer)img); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
184 } |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
185 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
186 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
187 static PurpleStoredImage * |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
188 purple_buddy_icon_data_new(guchar *icon_data, size_t icon_len, const char *filename) |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
189 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
190 char *file; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
191 PurpleStoredImage *img; |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
192 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
193 g_return_val_if_fail(icon_data != NULL, NULL); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
194 g_return_val_if_fail(icon_len > 0, NULL); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
195 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
196 if (filename == NULL) |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
197 { |
18039
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
16981
diff
changeset
|
198 file = purple_util_get_image_filename(icon_data, icon_len); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
199 if (file == NULL) |
16391
24bbd7e46bfe
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@wiktel.com>
parents:
16390
diff
changeset
|
200 { |
24bbd7e46bfe
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@wiktel.com>
parents:
16390
diff
changeset
|
201 g_free(icon_data); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
202 return NULL; |
16391
24bbd7e46bfe
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@wiktel.com>
parents:
16390
diff
changeset
|
203 } |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
204 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
205 else |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
206 file = g_strdup(filename); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
207 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
208 if ((img = g_hash_table_lookup(icon_data_cache, file))) |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
209 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
210 g_free(file); |
16391
24bbd7e46bfe
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@wiktel.com>
parents:
16390
diff
changeset
|
211 g_free(icon_data); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
212 return purple_imgstore_ref(img); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
213 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
214 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
215 img = purple_imgstore_add(icon_data, icon_len, file); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
216 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
217 /* This will take ownership of file and g_free it either now or later. */ |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
218 g_hash_table_insert(icon_data_cache, file, img); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
219 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
220 purple_buddy_icon_data_cache(img); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
221 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
222 return img; |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
223 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
224 |
15823 | 225 static PurpleBuddyIcon * |
226 purple_buddy_icon_create(PurpleAccount *account, const char *username) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
227 { |
15823 | 228 PurpleBuddyIcon *icon; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
229 GHashTable *icon_cache; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
231 /* This does not zero. See purple_buddy_icon_new() for |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
232 * information on which function allocates which member. */ |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
233 icon = g_slice_new(PurpleBuddyIcon); |
15823 | 234 PURPLE_DBUS_REGISTER_POINTER(icon, PurpleBuddyIcon); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
235 |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
236 icon->account = account; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
237 icon->username = g_strdup(username); |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
238 icon->checksum = NULL; |
16879
a1858493abe2
Fix a reference counting bug.
Richard Laager <rlaager@wiktel.com>
parents:
16858
diff
changeset
|
239 icon->ref_count = 1; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 icon_cache = g_hash_table_lookup(account_cache, account); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
243 if (icon_cache == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 icon_cache = g_hash_table_new(g_str_hash, g_str_equal); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
246 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 g_hash_table_insert(account_cache, account, icon_cache); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
249 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 g_hash_table_insert(icon_cache, |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
251 (char *)purple_buddy_icon_get_username(icon), icon); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 return icon; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
254 |
15823 | 255 PurpleBuddyIcon * |
256 purple_buddy_icon_new(PurpleAccount *account, const char *username, | |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
257 void *icon_data, size_t icon_len, |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
258 const char *checksum) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
259 { |
15823 | 260 PurpleBuddyIcon *icon; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
261 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
262 g_return_val_if_fail(account != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
263 g_return_val_if_fail(username != NULL, NULL); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
264 g_return_val_if_fail(icon_data != NULL, NULL); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
265 g_return_val_if_fail(icon_len > 0, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 |
16376
dd47fa8ba3e4
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@wiktel.com>
parents:
16375
diff
changeset
|
267 /* purple_buddy_icons_find() does allocation, so be |
dd47fa8ba3e4
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@wiktel.com>
parents:
16375
diff
changeset
|
268 * sure to update it as well when members are added. */ |
15823 | 269 icon = purple_buddy_icons_find(account, username); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
271 /* purple_buddy_icon_create() sets account & username */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
272 if (icon == NULL) |
15823 | 273 icon = purple_buddy_icon_create(account, username); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
274 |
16376
dd47fa8ba3e4
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@wiktel.com>
parents:
16375
diff
changeset
|
275 /* purple_buddy_icon_set_data() sets img, but it |
dd47fa8ba3e4
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@wiktel.com>
parents:
16375
diff
changeset
|
276 * references img first, so we need to initialize it */ |
dd47fa8ba3e4
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@wiktel.com>
parents:
16375
diff
changeset
|
277 icon->img = NULL; |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
278 purple_buddy_icon_set_data(icon, icon_data, icon_len, checksum); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
279 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 return icon; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
282 |
15823 | 283 PurpleBuddyIcon * |
284 purple_buddy_icon_ref(PurpleBuddyIcon *icon) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
285 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
286 g_return_val_if_fail(icon != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
287 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
288 icon->ref_count++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
289 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
290 return icon; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
291 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
292 |
15823 | 293 PurpleBuddyIcon * |
294 purple_buddy_icon_unref(PurpleBuddyIcon *icon) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 { |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
296 if (icon == NULL) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
297 return NULL; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
298 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
299 g_return_val_if_fail(icon->ref_count > 0, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
300 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
301 icon->ref_count--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
302 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
303 if (icon->ref_count == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
304 { |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
305 GHashTable *icon_cache = g_hash_table_lookup(account_cache, purple_buddy_icon_get_account(icon)); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
306 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
307 if (icon_cache != NULL) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
308 g_hash_table_remove(icon_cache, purple_buddy_icon_get_username(icon)); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
309 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
310 g_free(icon->username); |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
311 g_free(icon->checksum); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
312 purple_imgstore_unref(icon->img); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
313 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
314 PURPLE_DBUS_UNREGISTER_POINTER(icon); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
315 g_slice_free(PurpleBuddyIcon, icon); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
316 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
317 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
318 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
319 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
320 return icon; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
321 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
322 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
323 void |
15823 | 324 purple_buddy_icon_update(PurpleBuddyIcon *icon) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
325 { |
15823 | 326 PurpleConversation *conv; |
327 PurpleAccount *account; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
328 const char *username; |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
329 PurpleBuddyIcon *icon_to_set; |
16817
10f175539cfe
Change a few functions to free a linked list while iterating through
Mark Doliner <mark@kingant.net>
parents:
16710
diff
changeset
|
330 GSList *buddies; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
331 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
332 g_return_if_fail(icon != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
333 |
15823 | 334 account = purple_buddy_icon_get_account(icon); |
335 username = purple_buddy_icon_get_username(icon); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
336 |
16833
52c776782b95
Protect icon with ref/unref guards since it may be freed over the course of the while() loop. I thought this would fix #398, but something else is wrong, too.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16832
diff
changeset
|
337 /* If no data exists (icon->img == NULL), then call the functions below |
52c776782b95
Protect icon with ref/unref guards since it may be freed over the course of the while() loop. I thought this would fix #398, but something else is wrong, too.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16832
diff
changeset
|
338 * with NULL to unset the icon. They will then unref the icon and it should |
52c776782b95
Protect icon with ref/unref guards since it may be freed over the course of the while() loop. I thought this would fix #398, but something else is wrong, too.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16832
diff
changeset
|
339 * be destroyed. The only way it wouldn't be destroyed is if someone |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
340 * else is holding a reference to it, in which case they can kill |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
341 * the icon when they realize it has no data. */ |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
342 icon_to_set = icon->img ? icon : NULL; |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
343 |
16833
52c776782b95
Protect icon with ref/unref guards since it may be freed over the course of the while() loop. I thought this would fix #398, but something else is wrong, too.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16832
diff
changeset
|
344 /* Ensure that icon remains valid throughout */ |
52c776782b95
Protect icon with ref/unref guards since it may be freed over the course of the while() loop. I thought this would fix #398, but something else is wrong, too.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16832
diff
changeset
|
345 if (icon) purple_buddy_icon_ref(icon); |
52c776782b95
Protect icon with ref/unref guards since it may be freed over the course of the while() loop. I thought this would fix #398, but something else is wrong, too.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16832
diff
changeset
|
346 |
16817
10f175539cfe
Change a few functions to free a linked list while iterating through
Mark Doliner <mark@kingant.net>
parents:
16710
diff
changeset
|
347 buddies = purple_find_buddies(account, username); |
10f175539cfe
Change a few functions to free a linked list while iterating through
Mark Doliner <mark@kingant.net>
parents:
16710
diff
changeset
|
348 while (buddies != NULL) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
349 { |
16817
10f175539cfe
Change a few functions to free a linked list while iterating through
Mark Doliner <mark@kingant.net>
parents:
16710
diff
changeset
|
350 PurpleBuddy *buddy = (PurpleBuddy *)buddies->data; |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
351 char *old_icon; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
352 |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
353 purple_buddy_set_icon(buddy, icon_to_set); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
354 old_icon = g_strdup(purple_blist_node_get_string((PurpleBlistNode *)buddy, |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
355 "buddy_icon")); |
16378
bae921154351
If we're not caching icons, then don't save the filename.
Richard Laager <rlaager@wiktel.com>
parents:
16377
diff
changeset
|
356 if (icon->img && purple_buddy_icons_is_caching()) |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
357 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
358 const char *filename = purple_imgstore_get_filename(icon->img); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
359 purple_blist_node_set_string((PurpleBlistNode *)buddy, |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
360 "buddy_icon", |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
361 filename); |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
362 |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
363 if (icon->checksum && *icon->checksum) |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
364 { |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
365 purple_blist_node_set_string((PurpleBlistNode *)buddy, |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
366 "icon_checksum", |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
367 icon->checksum); |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
368 } |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
369 else |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
370 { |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
371 purple_blist_node_remove_setting((PurpleBlistNode *)buddy, |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
372 "icon_checksum"); |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
373 } |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
374 ref_filename(filename); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
375 } |
16981
a520e48dbfef
Patch from ticket #819 from vampire
Richard Laager <rlaager@wiktel.com>
parents:
16879
diff
changeset
|
376 else if (!icon->img) |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
377 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
378 purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "buddy_icon"); |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
379 purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "icon_checksum"); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
380 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
381 unref_filename(old_icon); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
382 g_free(old_icon); |
16817
10f175539cfe
Change a few functions to free a linked list while iterating through
Mark Doliner <mark@kingant.net>
parents:
16710
diff
changeset
|
383 |
10f175539cfe
Change a few functions to free a linked list while iterating through
Mark Doliner <mark@kingant.net>
parents:
16710
diff
changeset
|
384 buddies = g_slist_delete_link(buddies, buddies); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
385 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
386 |
15823 | 387 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, username, account); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
388 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
389 if (conv != NULL) |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
390 purple_conv_im_set_icon(PURPLE_CONV_IM(conv), icon_to_set); |
16833
52c776782b95
Protect icon with ref/unref guards since it may be freed over the course of the while() loop. I thought this would fix #398, but something else is wrong, too.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16832
diff
changeset
|
391 |
52c776782b95
Protect icon with ref/unref guards since it may be freed over the course of the while() loop. I thought this would fix #398, but something else is wrong, too.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16832
diff
changeset
|
392 /* icon's refcount was incremented above */ |
52c776782b95
Protect icon with ref/unref guards since it may be freed over the course of the while() loop. I thought this would fix #398, but something else is wrong, too.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16832
diff
changeset
|
393 if (icon) purple_buddy_icon_unref(icon); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
394 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
396 void |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
397 purple_buddy_icon_set_data(PurpleBuddyIcon *icon, guchar *data, |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
398 size_t len, const char *checksum) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
399 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
400 PurpleStoredImage *old_img; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
402 g_return_if_fail(icon != NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
403 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
404 old_img = icon->img; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
405 icon->img = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
406 |
16391
24bbd7e46bfe
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@wiktel.com>
parents:
16390
diff
changeset
|
407 if (data != NULL) |
16482
3be560001d26
Kill some compiler warnings and TODOs of mine.
Richard Laager <rlaager@wiktel.com>
parents:
16391
diff
changeset
|
408 { |
16391
24bbd7e46bfe
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@wiktel.com>
parents:
16390
diff
changeset
|
409 if (len > 0) |
24bbd7e46bfe
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@wiktel.com>
parents:
16390
diff
changeset
|
410 icon->img = purple_buddy_icon_data_new(data, len, NULL); |
24bbd7e46bfe
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@wiktel.com>
parents:
16390
diff
changeset
|
411 else |
24bbd7e46bfe
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@wiktel.com>
parents:
16390
diff
changeset
|
412 g_free(data); |
16482
3be560001d26
Kill some compiler warnings and TODOs of mine.
Richard Laager <rlaager@wiktel.com>
parents:
16391
diff
changeset
|
413 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
414 |
16832
844ed0418744
Remove two warnings, one compile-time, one runtime. Plug two leaks, both runtime.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16817
diff
changeset
|
415 g_free(icon->checksum); |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
416 icon->checksum = g_strdup(checksum); |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
417 |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
418 purple_buddy_icon_update(icon); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
419 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
420 purple_imgstore_unref(old_img); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
422 |
15823 | 423 PurpleAccount * |
424 purple_buddy_icon_get_account(const PurpleBuddyIcon *icon) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
425 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
426 g_return_val_if_fail(icon != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
427 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
428 return icon->account; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
429 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 const char * |
15823 | 432 purple_buddy_icon_get_username(const PurpleBuddyIcon *icon) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
433 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
434 g_return_val_if_fail(icon != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
435 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
436 return icon->username; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
437 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
438 |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
439 const char * |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
440 purple_buddy_icon_get_checksum(const PurpleBuddyIcon *icon) |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
441 { |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
442 g_return_val_if_fail(icon != NULL, NULL); |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
443 |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
444 return icon->checksum; |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
445 } |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
446 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
447 gconstpointer |
15823 | 448 purple_buddy_icon_get_data(const PurpleBuddyIcon *icon, size_t *len) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
449 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
450 g_return_val_if_fail(icon != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
451 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
452 if (icon->img) |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
453 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
454 if (len != NULL) |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
455 *len = purple_imgstore_get_size(icon->img); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
456 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
457 return purple_imgstore_get_data(icon->img); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
458 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
459 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
460 return NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
461 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
462 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
463 const char * |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
464 purple_buddy_icon_get_extension(const PurpleBuddyIcon *icon) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
465 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
466 if (icon->img != NULL) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
467 return purple_imgstore_get_extension(icon->img); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
468 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
469 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
471 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
472 void |
15823 | 473 purple_buddy_icons_set_for_user(PurpleAccount *account, const char *username, |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
474 void *icon_data, size_t icon_len, |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
475 const char *checksum) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
476 { |
16828
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
477 GHashTable *icon_cache; |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
478 PurpleBuddyIcon *icon = NULL; |
16389
493ca924c199
I'm stupid. If an icon doesn't exist, it's a good idea to create it when we want to fill it with data, not when we don't.
Richard Laager <rlaager@wiktel.com>
parents:
16386
diff
changeset
|
479 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
480 g_return_if_fail(account != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
481 g_return_if_fail(username != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
482 |
16828
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
483 icon_cache = g_hash_table_lookup(account_cache, account); |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
484 |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
485 if (icon_cache != NULL) |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
486 icon = g_hash_table_lookup(icon_cache, username); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
487 |
16389
493ca924c199
I'm stupid. If an icon doesn't exist, it's a good idea to create it when we want to fill it with data, not when we don't.
Richard Laager <rlaager@wiktel.com>
parents:
16386
diff
changeset
|
488 if (icon != NULL) |
493ca924c199
I'm stupid. If an icon doesn't exist, it's a good idea to create it when we want to fill it with data, not when we don't.
Richard Laager <rlaager@wiktel.com>
parents:
16386
diff
changeset
|
489 purple_buddy_icon_set_data(icon, icon_data, icon_len, checksum); |
16832
844ed0418744
Remove two warnings, one compile-time, one runtime. Plug two leaks, both runtime.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16817
diff
changeset
|
490 else if (icon_data && icon_len > 0) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
491 { |
20350
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
492 PurpleBuddyIcon *icon = purple_buddy_icon_new(account, username, icon_data, icon_len, checksum); |
16828
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
493 |
20350
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
494 /* purple_buddy_icon_new() calls |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
495 * purple_buddy_icon_set_data(), which calls |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
496 * purple_buddy_icon_update(), which has the buddy list |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
497 * and conversations take references as appropriate. |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
498 * This function doesn't return icon, so we can't |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
499 * leave a reference dangling. */ |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
500 purple_buddy_icon_unref(icon); |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
501 } |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
502 else |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
503 { |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
504 /* If the buddy list or a conversation was holding a |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
505 * reference, we'd have found the icon in the cache. |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
506 * Since we know we're deleting the icon, we only |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
507 * need a subset of purple_buddy_icon_update(). */ |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
508 |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
509 GSList *buddies = purple_find_buddies(account, username); |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
510 while (buddies != NULL) |
16828
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
511 { |
20350
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
512 PurpleBuddy *buddy = (PurpleBuddy *)buddies->data; |
16828
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
513 |
20350
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
514 unref_filename(purple_blist_node_get_string((PurpleBlistNode *)buddy, "buddy_icon")); |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
515 purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "buddy_icon"); |
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
516 purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "icon_checksum"); |
16828
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
517 |
20350
4d4eb6831722
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
518 buddies = g_slist_delete_link(buddies, buddies); |
16828
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
519 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
520 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
521 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
522 |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
523 char *purple_buddy_icon_get_full_path(PurpleBuddyIcon *icon) |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
524 { |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
525 char *path; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
526 |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
527 g_return_val_if_fail(icon != NULL, NULL); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
528 |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
529 if (icon->img == NULL) |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
530 return NULL; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
531 |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
532 path = g_build_filename(purple_buddy_icons_get_cache_dir(), |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
533 purple_imgstore_get_filename(icon->img), NULL); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
534 if (!g_file_test(path, G_FILE_TEST_EXISTS)) |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
535 { |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
536 g_free(path); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
537 return NULL; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
538 } |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
539 return path; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
540 } |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
541 |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
542 const char * |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
543 purple_buddy_icons_get_checksum_for_user(PurpleBuddy *buddy) |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
544 { |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
545 return purple_blist_node_get_string((PurpleBlistNode*)buddy, |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
546 "icon_checksum"); |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
547 } |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
548 |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
549 static gboolean |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
550 read_icon_file(const char *path, guchar **data, size_t *len) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
551 { |
16384
54ea8863b8e8
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@wiktel.com>
parents:
16383
diff
changeset
|
552 GError *err = NULL; |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
553 |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
554 if (!g_file_get_contents(path, (gchar **)data, len, &err)) |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
555 { |
16384
54ea8863b8e8
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@wiktel.com>
parents:
16383
diff
changeset
|
556 purple_debug_error("buddyicon", "Error reading %s: %s\n", |
54ea8863b8e8
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@wiktel.com>
parents:
16383
diff
changeset
|
557 path, err->message); |
54ea8863b8e8
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@wiktel.com>
parents:
16383
diff
changeset
|
558 g_error_free(err); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
559 |
16384
54ea8863b8e8
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@wiktel.com>
parents:
16383
diff
changeset
|
560 return FALSE; |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
561 } |
16384
54ea8863b8e8
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@wiktel.com>
parents:
16383
diff
changeset
|
562 |
54ea8863b8e8
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@wiktel.com>
parents:
16383
diff
changeset
|
563 return TRUE; |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
564 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
565 |
15823 | 566 PurpleBuddyIcon * |
567 purple_buddy_icons_find(PurpleAccount *account, const char *username) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
568 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
569 GHashTable *icon_cache; |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
570 PurpleBuddyIcon *icon = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
571 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
572 g_return_val_if_fail(account != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
573 g_return_val_if_fail(username != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
574 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
575 icon_cache = g_hash_table_lookup(account_cache, account); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
576 |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
577 if ((icon_cache == NULL) || ((icon = g_hash_table_lookup(icon_cache, username)) == NULL)) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
578 { |
15823 | 579 PurpleBuddy *b = purple_find_buddy(account, username); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
580 const char *protocol_icon_file; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
581 const char *dirname; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
582 gboolean caching; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
583 guchar *data; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
584 size_t len; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
585 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
586 if (!b) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
587 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
588 |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
589 protocol_icon_file = purple_blist_node_get_string((PurpleBlistNode*)b, "buddy_icon"); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
590 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
591 if (protocol_icon_file == NULL) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
592 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
593 |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
594 dirname = purple_buddy_icons_get_cache_dir(); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
595 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
596 caching = purple_buddy_icons_is_caching(); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
597 /* By disabling caching temporarily, we avoid a loop |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
598 * and don't have to add special code through several |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
599 * functions. */ |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
600 purple_buddy_icons_set_caching(FALSE); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
601 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
602 if (protocol_icon_file != NULL) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
603 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
604 char *path = g_build_filename(dirname, protocol_icon_file, NULL); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
605 if (read_icon_file(path, &data, &len)) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
606 { |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
607 const char *checksum; |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
608 |
16832
844ed0418744
Remove two warnings, one compile-time, one runtime. Plug two leaks, both runtime.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16817
diff
changeset
|
609 icon = purple_buddy_icon_create(account, username); |
16376
dd47fa8ba3e4
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@wiktel.com>
parents:
16375
diff
changeset
|
610 icon->img = NULL; |
16832
844ed0418744
Remove two warnings, one compile-time, one runtime. Plug two leaks, both runtime.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16817
diff
changeset
|
611 checksum = purple_blist_node_get_string((PurpleBlistNode*)b, "icon_checksum"); |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
612 purple_buddy_icon_set_data(icon, data, len, checksum); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
613 } |
22025
6f452e8d13a2
If the cached buddy icon can't be loaded, delete the preferences which point to it. Among other things, this fixes OSCAR buddy icon retrieval when the cache has been removed - since previously the icon hash was kept around and was used to determine that (so far as the prpl could tell) no icon retrieval was needed, libpurple would never have an icon for the contact.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21988
diff
changeset
|
614 else |
6f452e8d13a2
If the cached buddy icon can't be loaded, delete the preferences which point to it. Among other things, this fixes OSCAR buddy icon retrieval when the cache has been removed - since previously the icon hash was kept around and was used to determine that (so far as the prpl could tell) no icon retrieval was needed, libpurple would never have an icon for the contact.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21988
diff
changeset
|
615 delete_buddy_icon_settings((PurpleBlistNode*)b, "buddy_icon"); |
22033
684f9228ae92
Remove spurious braces
Evan Schoenberg <evan.s@dreskin.net>
parents:
22027
diff
changeset
|
616 |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
617 g_free(path); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
618 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
619 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
620 purple_buddy_icons_set_caching(caching); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
621 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
622 |
22040
72712558e2be
Apparently "nil" is an Objective-C thing
Stu Tomlinson <stu@nosnilmot.com>
parents:
22035
diff
changeset
|
623 return (icon ? purple_buddy_icon_ref(icon) : NULL); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
624 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
625 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
626 gboolean |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
627 purple_buddy_icons_has_custom_icon(PurpleContact *contact) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
628 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
629 g_return_val_if_fail(contact != NULL, FALSE); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
630 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
631 return (purple_blist_node_get_string((PurpleBlistNode*)contact, "custom_buddy_icon") != NULL); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
632 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
633 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
634 PurpleStoredImage * |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
635 purple_buddy_icons_find_account_icon(PurpleAccount *account) |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
636 { |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
637 PurpleStoredImage *img; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
638 const char *account_icon_file; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
639 const char *dirname; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
640 char *path; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
641 guchar *data; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
642 size_t len; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
643 |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
644 g_return_val_if_fail(account != NULL, NULL); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
645 |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
646 if ((img = g_hash_table_lookup(pointer_icon_cache, account))) |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
647 { |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
648 return purple_imgstore_ref(img); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
649 } |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
650 |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
651 account_icon_file = purple_account_get_string(account, "buddy_icon", NULL); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
652 |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
653 if (account_icon_file == NULL) |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
654 return NULL; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
655 |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
656 dirname = purple_buddy_icons_get_cache_dir(); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
657 path = g_build_filename(dirname, account_icon_file, NULL); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
658 |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
659 if (read_icon_file(path, &data, &len)) |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
660 { |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
661 g_free(path); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
662 img = purple_buddy_icon_data_new(data, len, account_icon_file); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
663 g_hash_table_insert(pointer_icon_cache, account, img); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
664 return img; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
665 } |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
666 g_free(path); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
667 |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
668 return NULL; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
669 } |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
670 |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
671 PurpleStoredImage * |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
672 purple_buddy_icons_set_account_icon(PurpleAccount *account, |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
673 guchar *icon_data, size_t icon_len) |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
674 { |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
675 PurpleStoredImage *old_img; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
676 PurpleStoredImage *img = NULL; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
677 char *old_icon; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
678 |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
679 if (icon_data != NULL && icon_len > 0) |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
680 { |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
681 img = purple_buddy_icon_data_new(icon_data, icon_len, NULL); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
682 } |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
683 |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
684 old_icon = g_strdup(purple_account_get_string(account, "buddy_icon", NULL)); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
685 if (img && purple_buddy_icons_is_caching()) |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
686 { |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
687 const char *filename = purple_imgstore_get_filename(img); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
688 purple_account_set_string(account, "buddy_icon", filename); |
16621
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
689 purple_account_set_int(account, "buddy_icon_timestamp", time(NULL)); |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
690 ref_filename(filename); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
691 } |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
692 else |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
693 { |
16482
3be560001d26
Kill some compiler warnings and TODOs of mine.
Richard Laager <rlaager@wiktel.com>
parents:
16391
diff
changeset
|
694 purple_account_set_string(account, "buddy_icon", NULL); |
16621
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
695 purple_account_set_int(account, "buddy_icon_timestamp", 0); |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
696 } |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
697 unref_filename(old_icon); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
698 |
22401
d9105ead88dc
When purple_buddy_icons_set_account_icon() is called, it unrefs the old PurpleStoredImage and refs the new one. Previously, it notified the prpl of the change in the buddy icon before updating pointer_icon_cache, which meant that if the prpl then called purple_buddy_icons_find_account_icon() it would get the old PurpleStoredImage (which is at this point not only old but also a pointer to invalid memory if unref'ing it caused it to be destroyed). This happens in jabber_set_info() as of 2.4.0, causing a crash when setting no-buddy-icon for an account after it has previously had an icon. I think this also means that XMPP accounts in 2.4.0 will also always set serverside the *last* icon set, not the current one, when changing icons, but I didn't test that.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22262
diff
changeset
|
699 if (img) |
d9105ead88dc
When purple_buddy_icons_set_account_icon() is called, it unrefs the old PurpleStoredImage and refs the new one. Previously, it notified the prpl of the change in the buddy icon before updating pointer_icon_cache, which meant that if the prpl then called purple_buddy_icons_find_account_icon() it would get the old PurpleStoredImage (which is at this point not only old but also a pointer to invalid memory if unref'ing it caused it to be destroyed). This happens in jabber_set_info() as of 2.4.0, causing a crash when setting no-buddy-icon for an account after it has previously had an icon. I think this also means that XMPP accounts in 2.4.0 will also always set serverside the *last* icon set, not the current one, when changing icons, but I didn't test that.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22262
diff
changeset
|
700 g_hash_table_insert(pointer_icon_cache, account, img); |
d9105ead88dc
When purple_buddy_icons_set_account_icon() is called, it unrefs the old PurpleStoredImage and refs the new one. Previously, it notified the prpl of the change in the buddy icon before updating pointer_icon_cache, which meant that if the prpl then called purple_buddy_icons_find_account_icon() it would get the old PurpleStoredImage (which is at this point not only old but also a pointer to invalid memory if unref'ing it caused it to be destroyed). This happens in jabber_set_info() as of 2.4.0, causing a crash when setting no-buddy-icon for an account after it has previously had an icon. I think this also means that XMPP accounts in 2.4.0 will also always set serverside the *last* icon set, not the current one, when changing icons, but I didn't test that.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22262
diff
changeset
|
701 else |
d9105ead88dc
When purple_buddy_icons_set_account_icon() is called, it unrefs the old PurpleStoredImage and refs the new one. Previously, it notified the prpl of the change in the buddy icon before updating pointer_icon_cache, which meant that if the prpl then called purple_buddy_icons_find_account_icon() it would get the old PurpleStoredImage (which is at this point not only old but also a pointer to invalid memory if unref'ing it caused it to be destroyed). This happens in jabber_set_info() as of 2.4.0, causing a crash when setting no-buddy-icon for an account after it has previously had an icon. I think this also means that XMPP accounts in 2.4.0 will also always set serverside the *last* icon set, not the current one, when changing icons, but I didn't test that.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22262
diff
changeset
|
702 g_hash_table_remove(pointer_icon_cache, account); |
d9105ead88dc
When purple_buddy_icons_set_account_icon() is called, it unrefs the old PurpleStoredImage and refs the new one. Previously, it notified the prpl of the change in the buddy icon before updating pointer_icon_cache, which meant that if the prpl then called purple_buddy_icons_find_account_icon() it would get the old PurpleStoredImage (which is at this point not only old but also a pointer to invalid memory if unref'ing it caused it to be destroyed). This happens in jabber_set_info() as of 2.4.0, causing a crash when setting no-buddy-icon for an account after it has previously had an icon. I think this also means that XMPP accounts in 2.4.0 will also always set serverside the *last* icon set, not the current one, when changing icons, but I didn't test that.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22262
diff
changeset
|
703 |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
704 if (purple_account_is_connected(account)) |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
705 { |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
706 PurpleConnection *gc; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
707 PurplePluginProtocolInfo *prpl_info; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
708 |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
709 gc = purple_account_get_connection(account); |
22262
edca47ee06c5
Kill off gc->prpl in the core everywhere but connection.c (when the struct
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22185
diff
changeset
|
710 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
711 |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
712 if (prpl_info && prpl_info->set_buddy_icon) |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
713 prpl_info->set_buddy_icon(gc, img); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
714 } |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
715 |
21588
837c382af6a4
prpl->set_buddy_icon may keep a reference to PurpleStoredImage, move the
Ka-Hing Cheung <khc@hxbc.us>
parents:
21121
diff
changeset
|
716 if ((old_img = g_hash_table_lookup(pointer_icon_cache, account))) |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
717 purple_imgstore_unref(old_img); |
16616
4eb08fcc16d8
Fix assertion when creating a new account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
16596
diff
changeset
|
718 else if (old_icon) |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
719 { |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
720 /* The old icon may not have been loaded into memory. In that |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
721 * case, we'll need to uncache the filename. The filenames |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
722 * are ref-counted, so this is safe. */ |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
723 purple_buddy_icon_data_uncache_file(old_icon); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
724 } |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
725 g_free(old_icon); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
726 |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
727 return img; |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
728 } |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
729 |
16621
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
730 time_t |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
731 purple_buddy_icons_get_account_icon_timestamp(PurpleAccount *account) |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
732 { |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
733 time_t ret; |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
734 |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
735 g_return_val_if_fail(account != NULL, 0); |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
736 |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
737 ret = purple_account_get_int(account, "buddy_icon_timestamp", 0); |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
738 |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
739 /* This deals with migration cases. */ |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
740 if (ret == 0 && purple_account_get_string(account, "buddy_icon", NULL) != NULL) |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
741 { |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
742 ret = time(NULL); |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
743 purple_account_set_int(account, "buddy_icon_timestamp", ret); |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
744 } |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
745 |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
746 return ret; |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
747 } |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
748 |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
749 PurpleStoredImage * |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
750 purple_buddy_icons_find_custom_icon(PurpleContact *contact) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
751 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
752 PurpleStoredImage *img; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
753 const char *custom_icon_file; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
754 const char *dirname; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
755 char *path; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
756 guchar *data; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
757 size_t len; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
758 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
759 g_return_val_if_fail(contact != NULL, NULL); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
760 |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
761 if ((img = g_hash_table_lookup(pointer_icon_cache, contact))) |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
762 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
763 return purple_imgstore_ref(img); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
764 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
765 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
766 custom_icon_file = purple_blist_node_get_string((PurpleBlistNode*)contact, "custom_buddy_icon"); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
767 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
768 if (custom_icon_file == NULL) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
769 return NULL; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
770 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
771 dirname = purple_buddy_icons_get_cache_dir(); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
772 path = g_build_filename(dirname, custom_icon_file, NULL); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
773 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
774 if (read_icon_file(path, &data, &len)) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
775 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
776 g_free(path); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
777 img = purple_buddy_icon_data_new(data, len, custom_icon_file); |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
778 g_hash_table_insert(pointer_icon_cache, contact, img); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
779 return img; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
780 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
781 g_free(path); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
782 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
783 return NULL; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
784 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
785 |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
786 PurpleStoredImage * |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
787 purple_buddy_icons_set_custom_icon(PurpleContact *contact, |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
788 guchar *icon_data, size_t icon_len) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
789 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
790 PurpleStoredImage *old_img; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
791 PurpleStoredImage *img = NULL; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
792 char *old_icon; |
16381
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
793 PurpleBlistNode *child; |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
794 |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
795 old_img = g_hash_table_lookup(pointer_icon_cache, contact); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
796 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
797 if (icon_data != NULL && icon_len > 0) |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
798 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
799 img = purple_buddy_icon_data_new(icon_data, icon_len, NULL); |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
800 } |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
801 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
802 old_icon = g_strdup(purple_blist_node_get_string((PurpleBlistNode *)contact, |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
803 "custom_buddy_icon")); |
16378
bae921154351
If we're not caching icons, then don't save the filename.
Richard Laager <rlaager@wiktel.com>
parents:
16377
diff
changeset
|
804 if (img && purple_buddy_icons_is_caching()) |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
805 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
806 const char *filename = purple_imgstore_get_filename(img); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
807 purple_blist_node_set_string((PurpleBlistNode *)contact, |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
808 "custom_buddy_icon", |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
809 filename); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
810 ref_filename(filename); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
811 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
812 else |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
813 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
814 purple_blist_node_remove_setting((PurpleBlistNode *)contact, |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
815 "custom_buddy_icon"); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
816 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
817 unref_filename(old_icon); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
818 |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
819 if (img) |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
820 g_hash_table_insert(pointer_icon_cache, contact, img); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
821 else |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
822 g_hash_table_remove(pointer_icon_cache, contact); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
823 |
16381
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
824 for (child = contact->node.child ; child ; child = child->next) |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
825 { |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
826 PurpleBuddy *buddy; |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
827 PurpleConversation *conv; |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
828 |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
829 if (!PURPLE_BLIST_NODE_IS_BUDDY(child)) |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
830 continue; |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
831 |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
832 buddy = (PurpleBuddy *)child; |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
833 |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
834 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
835 purple_buddy_get_name(buddy), |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
836 purple_buddy_get_account(buddy)); |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
837 if (conv) |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
838 purple_conversation_update(conv, PURPLE_CONV_UPDATE_ICON); |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
839 |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
840 purple_blist_update_buddy_icon(buddy); |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
841 } |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
842 |
16385
a0df0eb75e1b
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@wiktel.com>
parents:
16384
diff
changeset
|
843 if (old_img) |
a0df0eb75e1b
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@wiktel.com>
parents:
16384
diff
changeset
|
844 purple_imgstore_unref(old_img); |
16667
df5fb079b1ad
This gets rid of a g_log error when uncache-ing a NULL file.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16637
diff
changeset
|
845 else if (old_icon) |
16385
a0df0eb75e1b
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@wiktel.com>
parents:
16384
diff
changeset
|
846 { |
a0df0eb75e1b
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@wiktel.com>
parents:
16384
diff
changeset
|
847 /* The old icon may not have been loaded into memory. In that |
a0df0eb75e1b
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@wiktel.com>
parents:
16384
diff
changeset
|
848 * case, we'll need to uncache the filename. The filenames |
a0df0eb75e1b
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@wiktel.com>
parents:
16384
diff
changeset
|
849 * are ref-counted, so this is safe. */ |
a0df0eb75e1b
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@wiktel.com>
parents:
16384
diff
changeset
|
850 purple_buddy_icon_data_uncache_file(old_icon); |
a0df0eb75e1b
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@wiktel.com>
parents:
16384
diff
changeset
|
851 } |
a0df0eb75e1b
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@wiktel.com>
parents:
16384
diff
changeset
|
852 g_free(old_icon); |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
853 |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
854 return img; |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
855 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
856 |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
857 void |
16637
250623ba4218
The GNOME coding guidelines recommend prefixing internal symbols with an underscore.
Richard Laager <rlaager@wiktel.com>
parents:
16631
diff
changeset
|
858 _purple_buddy_icon_set_old_icons_dir(const char *dirname) |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
859 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
860 old_icons_dir = g_strdup(dirname); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
861 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
862 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
863 static void |
16551
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
864 delete_buddy_icon_settings(PurpleBlistNode *node, const char *setting_name) |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
865 { |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
866 purple_blist_node_remove_setting(node, setting_name); |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
867 |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
868 if (!strcmp(setting_name, "buddy_icon")) |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
869 { |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
870 purple_blist_node_remove_setting(node, "avatar_hash"); |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
871 purple_blist_node_remove_setting(node, "icon_checksum"); |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
872 } |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
873 } |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
874 |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
875 static void |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
876 migrate_buddy_icon(PurpleBlistNode *node, const char *setting_name, |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
877 const char *dirname, const char *filename) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
878 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
879 char *path; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
880 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
881 if (filename[0] != '/') |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
882 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
883 path = g_build_filename(dirname, filename, NULL); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
884 if (g_file_test(path, G_FILE_TEST_EXISTS)) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
885 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
886 g_free(path); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
887 return; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
888 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
889 g_free(path); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
890 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
891 path = g_build_filename(old_icons_dir, filename, NULL); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
892 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
893 else |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
894 path = g_strdup(filename); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
895 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
896 if (g_file_test(path, G_FILE_TEST_EXISTS)) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
897 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
898 guchar *icon_data; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
899 size_t icon_len; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
900 FILE *file; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
901 char *new_filename; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
902 |
16629
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
903 if (!read_icon_file(path, &icon_data, &icon_len)) |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
904 { |
16629
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
905 g_free(path); |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
906 delete_buddy_icon_settings(node, setting_name); |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
907 return; |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
908 } |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
909 |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
910 if (icon_data == NULL || icon_len <= 0) |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
911 { |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
912 /* This really applies to the icon_len check. |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
913 * icon_data should never be NULL if |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
914 * read_icon_file() returns TRUE. */ |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
915 purple_debug_error("buddyicon", "Empty buddy icon file: %s\n", path); |
16551
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
916 delete_buddy_icon_settings(node, setting_name); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
917 g_free(path); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
918 return; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
919 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
920 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
921 g_free(path); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
922 |
18039
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
16981
diff
changeset
|
923 new_filename = purple_util_get_image_filename(icon_data, icon_len); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
924 if (new_filename == NULL) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
925 { |
16629
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
926 purple_debug_error("buddyicon", |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
927 "New icon filename is NULL. This should never happen! " |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
928 "The old filename was: %s\n", path); |
16551
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
929 delete_buddy_icon_settings(node, setting_name); |
16629
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
930 g_return_if_reached(); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
931 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
932 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
933 path = g_build_filename(dirname, new_filename, NULL); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
934 if ((file = g_fopen(path, "wb")) != NULL) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
935 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
936 if (!fwrite(icon_data, icon_len, 1, file)) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
937 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
938 purple_debug_error("buddyicon", "Error writing %s: %s\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20350
diff
changeset
|
939 path, g_strerror(errno)); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
940 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
941 else |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
942 purple_debug_info("buddyicon", "Wrote migrated cache file: %s\n", path); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
943 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
944 fclose(file); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
945 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
946 else |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
947 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
948 purple_debug_error("buddyicon", "Unable to create file %s: %s\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20350
diff
changeset
|
949 path, g_strerror(errno)); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
950 g_free(new_filename); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
951 g_free(path); |
16551
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
952 |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
953 delete_buddy_icon_settings(node, setting_name); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
954 return; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
955 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
956 g_free(path); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
957 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
958 purple_blist_node_set_string(node, |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
959 setting_name, |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
960 new_filename); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
961 ref_filename(new_filename); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
962 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
963 g_free(new_filename); |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
964 |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
965 if (!strcmp(setting_name, "buddy_icon")) |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
966 { |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
967 const char *hash; |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
968 |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
969 hash = purple_blist_node_get_string(node, "avatar_hash"); |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
970 if (hash != NULL) |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
971 { |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
972 purple_blist_node_set_string(node, "icon_checksum", hash); |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
973 purple_blist_node_remove_setting(node, "avatar_hash"); |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
974 } |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
975 else |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
976 { |
16569
d212880d8d5b
Make this yahoo hack compile.
Richard Laager <rlaager@wiktel.com>
parents:
16568
diff
changeset
|
977 PurpleAccount *account = purple_buddy_get_account((PurpleBuddy *)node); |
16568
8cd67084833c
In theory, this solves the massive pile of g_log errors that occur when
Richard Laager <rlaager@wiktel.com>
parents:
16553
diff
changeset
|
978 const char *prpl_id = purple_account_get_protocol_id(account); |
8cd67084833c
In theory, this solves the massive pile of g_log errors that occur when
Richard Laager <rlaager@wiktel.com>
parents:
16553
diff
changeset
|
979 |
8cd67084833c
In theory, this solves the massive pile of g_log errors that occur when
Richard Laager <rlaager@wiktel.com>
parents:
16553
diff
changeset
|
980 if (!strcmp(prpl_id, "prpl-yahoo")) |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
981 { |
16568
8cd67084833c
In theory, this solves the massive pile of g_log errors that occur when
Richard Laager <rlaager@wiktel.com>
parents:
16553
diff
changeset
|
982 int checksum = purple_blist_node_get_int(node, "icon_checksum"); |
8cd67084833c
In theory, this solves the massive pile of g_log errors that occur when
Richard Laager <rlaager@wiktel.com>
parents:
16553
diff
changeset
|
983 if (checksum != 0) |
8cd67084833c
In theory, this solves the massive pile of g_log errors that occur when
Richard Laager <rlaager@wiktel.com>
parents:
16553
diff
changeset
|
984 { |
8cd67084833c
In theory, this solves the massive pile of g_log errors that occur when
Richard Laager <rlaager@wiktel.com>
parents:
16553
diff
changeset
|
985 char *checksum_str = g_strdup_printf("%i", checksum); |
8cd67084833c
In theory, this solves the massive pile of g_log errors that occur when
Richard Laager <rlaager@wiktel.com>
parents:
16553
diff
changeset
|
986 purple_blist_node_remove_setting(node, "icon_checksum"); |
8cd67084833c
In theory, this solves the massive pile of g_log errors that occur when
Richard Laager <rlaager@wiktel.com>
parents:
16553
diff
changeset
|
987 purple_blist_node_set_string(node, "icon_checksum", checksum_str); |
8cd67084833c
In theory, this solves the massive pile of g_log errors that occur when
Richard Laager <rlaager@wiktel.com>
parents:
16553
diff
changeset
|
988 g_free(checksum_str); |
8cd67084833c
In theory, this solves the massive pile of g_log errors that occur when
Richard Laager <rlaager@wiktel.com>
parents:
16553
diff
changeset
|
989 } |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
990 } |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
991 } |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
992 } |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
993 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
994 else |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
995 { |
16629
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
996 purple_debug_error("buddyicon", "Old icon file doesn't exist: %s\n", path); |
16551
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
997 delete_buddy_icon_settings(node, setting_name); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
998 g_free(path); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
999 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1000 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1001 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1002 void |
16637
250623ba4218
The GNOME coding guidelines recommend prefixing internal symbols with an underscore.
Richard Laager <rlaager@wiktel.com>
parents:
16631
diff
changeset
|
1003 _purple_buddy_icons_account_loaded_cb() |
16505
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1004 { |
16508
c8bc8048f264
This is probably needed to compile.
Richard Laager <rlaager@wiktel.com>
parents:
16506
diff
changeset
|
1005 const char *dirname = purple_buddy_icons_get_cache_dir(); |
18063
926ccb104da0
disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents:
18058
diff
changeset
|
1006 GList *cur; |
16505
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1007 |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1008 for (cur = purple_accounts_get_all(); cur != NULL; cur = cur->next) |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1009 { |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1010 PurpleAccount *account = cur->data; |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1011 const char *account_icon_file = purple_account_get_string(account, "buddy_icon", NULL); |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1012 |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1013 if (account_icon_file != NULL) |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1014 { |
16510
c01528418cc2
I really shouldn't commit before compiling.
Richard Laager <rlaager@wiktel.com>
parents:
16508
diff
changeset
|
1015 char *path = g_build_filename(dirname, account_icon_file, NULL); |
c01528418cc2
I really shouldn't commit before compiling.
Richard Laager <rlaager@wiktel.com>
parents:
16508
diff
changeset
|
1016 if (!g_file_test(path, G_FILE_TEST_EXISTS)) |
16505
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1017 { |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1018 purple_account_set_string(account, "buddy_icon", NULL); |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1019 } else { |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1020 ref_filename(account_icon_file); |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1021 } |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1022 g_free(path); |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1023 } |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1024 } |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1025 } |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1026 |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1027 void |
16637
250623ba4218
The GNOME coding guidelines recommend prefixing internal symbols with an underscore.
Richard Laager <rlaager@wiktel.com>
parents:
16631
diff
changeset
|
1028 _purple_buddy_icons_blist_loaded_cb() |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1029 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1030 PurpleBlistNode *node = purple_blist_get_root(); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1031 const char *dirname = purple_buddy_icons_get_cache_dir(); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1032 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1033 /* Doing this once here saves having to check it inside a loop. */ |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1034 if (old_icons_dir != NULL) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1035 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1036 if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1037 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1038 purple_debug_info("buddyicon", "Creating icon cache directory.\n"); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1039 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1040 if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1041 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1042 purple_debug_error("buddyicon", |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1043 "Unable to create directory %s: %s\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20350
diff
changeset
|
1044 dirname, g_strerror(errno)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1045 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1046 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1047 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1048 |
16596
63a1de71e389
Whitespace fix from patch in ticket #383
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16569
diff
changeset
|
1049 while (node != NULL) |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1050 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1051 if (PURPLE_BLIST_NODE_IS_BUDDY(node)) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1052 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1053 const char *filename; |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1054 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1055 filename = purple_blist_node_get_string(node, "buddy_icon"); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1056 if (filename != NULL) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1057 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1058 if (old_icons_dir != NULL) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1059 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1060 migrate_buddy_icon(node, |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1061 "buddy_icon", |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1062 dirname, filename); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1063 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1064 else |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1065 { |
16381
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
1066 char *path = g_build_filename(dirname, filename, NULL); |
16506
d6b81413ef79
Fix a small-but-serious bug with the code to ref the buddy icons at load.
Richard Laager <rlaager@wiktel.com>
parents:
16505
diff
changeset
|
1067 if (!g_file_test(path, G_FILE_TEST_EXISTS)) |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1068 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1069 purple_blist_node_remove_setting(node, |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1070 "buddy_icon"); |
16386
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
1071 purple_blist_node_remove_setting(node, |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
1072 "icon_checksum"); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1073 } |
16383
05033ae856b2
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
1074 else |
05033ae856b2
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
1075 ref_filename(filename); |
16381
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
1076 g_free(path); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1077 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1078 } |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1079 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1080 else if (PURPLE_BLIST_NODE_IS_CONTACT(node)) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1081 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1082 const char *filename; |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1083 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1084 filename = purple_blist_node_get_string(node, "custom_buddy_icon"); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1085 if (filename != NULL) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1086 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1087 if (old_icons_dir != NULL) |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1088 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1089 migrate_buddy_icon(node, |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1090 "custom_buddy_icon", |
16552
e98cd6ed5c13
Minor whitespace tweak.
Richard Laager <rlaager@wiktel.com>
parents:
16551
diff
changeset
|
1091 dirname, filename); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1092 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1093 else |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1094 { |
16381
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
1095 char *path = g_build_filename(dirname, filename, NULL); |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
1096 if (!g_file_test(path, G_FILE_TEST_EXISTS)) |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1097 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1098 purple_blist_node_remove_setting(node, |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1099 "custom_buddy_icon"); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1100 } |
16383
05033ae856b2
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
1101 else |
05033ae856b2
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
1102 ref_filename(filename); |
16381
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
1103 g_free(path); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1104 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1105 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1106 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1107 node = purple_blist_node_next(node, TRUE); |
16596
63a1de71e389
Whitespace fix from patch in ticket #383
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16569
diff
changeset
|
1108 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1109 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1110 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1111 void |
15823 | 1112 purple_buddy_icons_set_caching(gboolean caching) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1113 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1114 icon_caching = caching; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1115 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1116 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1117 gboolean |
15823 | 1118 purple_buddy_icons_is_caching(void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1119 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1120 return icon_caching; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1121 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1122 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1123 void |
15823 | 1124 purple_buddy_icons_set_cache_dir(const char *dir) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1125 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1126 g_return_if_fail(dir != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1127 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1128 g_free(cache_dir); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1129 cache_dir = g_strdup(dir); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1130 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1131 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1132 const char * |
15823 | 1133 purple_buddy_icons_get_cache_dir(void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1134 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1135 return cache_dir; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1136 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1137 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1138 void * |
15823 | 1139 purple_buddy_icons_get_handle() |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1140 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1141 static int handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1142 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1143 return &handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1144 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1145 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1146 void |
15823 | 1147 purple_buddy_icons_init() |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1148 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1149 account_cache = g_hash_table_new_full( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1150 g_direct_hash, g_direct_equal, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1151 NULL, (GFreeFunc)g_hash_table_destroy); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1152 |
16611
f130f097e378
19:00:43 Ka-Hing Cheung (khc): rlaager: shouldn't we give g_free as the key free function for icon_data_cache?
Richard Laager <rlaager@wiktel.com>
parents:
16596
diff
changeset
|
1153 icon_data_cache = g_hash_table_new_full(g_str_hash, g_str_equal, |
f130f097e378
19:00:43 Ka-Hing Cheung (khc): rlaager: shouldn't we give g_free as the key free function for icon_data_cache?
Richard Laager <rlaager@wiktel.com>
parents:
16596
diff
changeset
|
1154 g_free, NULL); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1155 icon_file_cache = g_hash_table_new_full(g_str_hash, g_str_equal, |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1156 g_free, NULL); |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
1157 pointer_icon_cache = g_hash_table_new(g_direct_hash, g_direct_equal); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1158 |
22036
f4c0a7014498
If the UI sets a cache directory before purple_buddy_icons_init() is called
Evan Schoenberg <evan.s@dreskin.net>
parents:
22035
diff
changeset
|
1159 if (!cache_dir) |
f4c0a7014498
If the UI sets a cache directory before purple_buddy_icons_init() is called
Evan Schoenberg <evan.s@dreskin.net>
parents:
22035
diff
changeset
|
1160 cache_dir = g_build_filename(purple_user_dir(), "icons", NULL); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1161 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1162 purple_signal_connect(purple_imgstore_get_handle(), "image-deleting", |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1163 purple_buddy_icons_get_handle(), |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1164 G_CALLBACK(image_deleting_cb), NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1165 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1166 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1167 void |
15823 | 1168 purple_buddy_icons_uninit() |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1169 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1170 purple_signals_disconnect_by_handle(purple_buddy_icons_get_handle()); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1171 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1172 g_hash_table_destroy(account_cache); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1173 g_hash_table_destroy(icon_data_cache); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1174 g_hash_table_destroy(icon_file_cache); |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16389
diff
changeset
|
1175 g_hash_table_destroy(pointer_icon_cache); |
16373
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1176 g_free(old_icons_dir); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1177 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1178 |
15823 | 1179 void purple_buddy_icon_get_scale_size(PurpleBuddyIconSpec *spec, int *width, int *height) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1180 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1181 int new_width, new_height; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1182 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1183 new_width = *width; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1184 new_height = *height; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1185 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1186 if (*width < spec->min_width) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1187 new_width = spec->min_width; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1188 else if (*width > spec->max_width) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1189 new_width = spec->max_width; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1190 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1191 if (*height < spec->min_height) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1192 new_height = spec->min_height; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1193 else if (*height > spec->max_height) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1194 new_height = spec->max_height; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1195 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1196 /* preserve aspect ratio */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1197 if ((double)*height * (double)new_width > |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1198 (double)*width * (double)new_height) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1199 new_width = 0.5 + (double)*width * (double)new_height / (double)*height; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1200 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1201 new_height = 0.5 + (double)*height * (double)new_width / (double)*width; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1202 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1203 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1204 *width = new_width; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1205 *height = new_height; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1206 } |