Mercurial > pidgin.yaz
annotate libpurple/buddyicon.c @ 19201:73d8dd2169c4
In x509_ca pool:
- Complete the lazy_init function (still untested)
- Move most of the put_cert logic into quiet_put_cert, which adds a
certificate to the internal database and does nothing else (such as
adding it to a disk cache)
author | William Ehlhardt <williamehlhardt@gmail.com> |
---|---|
date | Mon, 13 Aug 2007 05:29:22 +0000 |
parents | 926ccb104da0 |
children | 44b4e8bd759b |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4 * |
15823 | 5 * purple |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
6 * |
15823 | 7 * 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
|
8 * 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
|
9 * source distribution. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * 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
|
12 * 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
|
13 * 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
|
14 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * 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
|
17 * 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
|
18 * 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
|
19 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * 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
|
22 * along with this program; if not, write to the Free Software |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 #include "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 #include "buddyicon.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 #include "conversation.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 #include "dbus-maybe.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #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
|
30 #include "imgstore.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include "util.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 |
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
|
33 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
|
34 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
35 /* 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
|
36 * 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
|
37 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
|
38 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
39 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
|
40 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
|
41 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
|
42 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
|
43 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
|
44 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
|
45 }; |
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 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 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
|
48 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
|
49 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
|
50 |
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 /* 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
|
52 * 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
|
53 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
|
54 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 static char *cache_dir = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 static gboolean icon_caching = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 |
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
|
58 /* 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
|
59 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
|
60 |
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 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
|
62 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
|
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 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
|
65 |
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 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
|
67 |
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 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
|
69 |
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 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
|
71 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
|
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 |
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 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
|
75 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
|
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 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
|
78 |
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 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
|
80 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
|
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 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
|
83 |
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 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
|
85 { |
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 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
|
87 } |
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 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
|
89 { |
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 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
|
91 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
|
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 } |
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 |
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 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
|
96 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
|
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 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
|
99 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
|
100 FILE *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
|
101 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
102 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
|
103 |
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
|
104 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
|
105 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
|
106 |
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 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
|
108 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
|
109 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
110 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
|
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 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
|
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 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
|
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 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
|
117 "Unable to create directory %s: %s\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
|
118 dirname, strerror(errno)); |
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 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
120 } |
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 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
|
123 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
124 if (!fwrite(purple_imgstore_get_data(img), purple_imgstore_get_size(img), 1, 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
|
125 { |
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 purple_debug_error("buddyicon", "Error writing %s: %s\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
|
127 path, strerror(errno)); |
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 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
|
130 purple_debug_info("buddyicon", "Wrote 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
|
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 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
|
133 } |
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 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
|
135 { |
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 purple_debug_error("buddyicon", "Unable to create file %s: %s\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
|
137 path, strerror(errno)); |
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 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
|
139 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
|
140 } |
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 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
|
142 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
143 |
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 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
|
145 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
|
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 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
|
148 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
|
149 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
150 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
|
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 /* 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
|
153 * 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
|
154 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
|
155 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
|
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 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
|
158 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
|
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 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
|
161 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
162 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
|
163 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
164 purple_debug_error("buddyicon", "Failed to delete %s: %s\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
|
165 path, strerror(errno)); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
166 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
167 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
|
168 { |
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 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
|
170 } |
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 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
172 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
173 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
|
174 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
175 |
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
|
176 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
|
177 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
|
178 { |
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
|
179 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
|
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 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
182 static void |
16688
61ddeb85ab86
Document the image-deleting signal.
Richard Laager <rlaager@wiktel.com>
parents:
16667
diff
changeset
|
183 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
|
184 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
185 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
|
186 |
16628
36981d83b20c
Fix a crash when removing a per-account icon. Here's my explanation:
Richard Laager <rlaager@wiktel.com>
parents:
16622
diff
changeset
|
187 /* 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
|
188 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
|
189 return; |
36981d83b20c
Fix a crash when removing a per-account icon. Here's my explanation:
Richard Laager <rlaager@wiktel.com>
parents:
16622
diff
changeset
|
190 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
191 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
|
192 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
193 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
|
194 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
|
195 |
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
|
196 /* 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
|
197 * this is probably good enough. */ |
16710
77cfd9bd6536
Get rid of two harmless warnings:
Mark Doliner <mark@kingant.net>
parents:
16688
diff
changeset
|
198 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
|
199 } |
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
|
200 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
201 |
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 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
|
203 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
|
204 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
205 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
|
206 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
|
207 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
208 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
|
209 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
|
210 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
211 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
|
212 { |
18039
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
16981
diff
changeset
|
213 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
|
214 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
|
215 { |
24bbd7e46bfe
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@wiktel.com>
parents:
16390
diff
changeset
|
216 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
|
217 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
|
218 } |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
219 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
220 else |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
221 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
|
222 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
223 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
|
224 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
225 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
|
226 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
|
227 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
|
228 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
229 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
230 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
|
231 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
232 /* 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
|
233 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
|
234 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
235 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
|
236 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
237 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
|
238 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
239 |
15823 | 240 static PurpleBuddyIcon * |
241 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
|
242 { |
15823 | 243 PurpleBuddyIcon *icon; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 GHashTable *icon_cache; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
246 /* 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
|
247 * 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
|
248 icon = g_slice_new(PurpleBuddyIcon); |
15823 | 249 PURPLE_DBUS_REGISTER_POINTER(icon, PurpleBuddyIcon); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 |
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 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
|
252 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
|
253 icon->checksum = NULL; |
16879
a1858493abe2
Fix a reference counting bug.
Richard Laager <rlaager@wiktel.com>
parents:
16858
diff
changeset
|
254 icon->ref_count = 1; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
255 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
256 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
|
257 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
258 if (icon_cache == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
259 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
260 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
|
261 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
262 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
|
263 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
265 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
|
266 (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
|
267 return icon; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 |
15823 | 270 PurpleBuddyIcon * |
271 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
|
272 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
|
273 const char *checksum) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
274 { |
15823 | 275 PurpleBuddyIcon *icon; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
277 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
|
278 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
|
279 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
|
280 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
|
281 |
16376
dd47fa8ba3e4
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@wiktel.com>
parents:
16375
diff
changeset
|
282 /* 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
|
283 * sure to update it as well when members are added. */ |
15823 | 284 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
|
285 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
286 /* 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
|
287 if (icon == NULL) |
15823 | 288 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
|
289 |
16376
dd47fa8ba3e4
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@wiktel.com>
parents:
16375
diff
changeset
|
290 /* 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
|
291 * 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
|
292 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
|
293 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
|
294 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 return icon; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
296 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
297 |
15823 | 298 PurpleBuddyIcon * |
299 purple_buddy_icon_ref(PurpleBuddyIcon *icon) | |
15374
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 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
|
302 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
303 icon->ref_count++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
304 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
305 return icon; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
306 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
307 |
15823 | 308 PurpleBuddyIcon * |
309 purple_buddy_icon_unref(PurpleBuddyIcon *icon) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
310 { |
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
|
311 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
|
312 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
|
313 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
314 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
|
315 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
316 icon->ref_count--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
317 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
318 if (icon->ref_count == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
319 { |
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
|
320 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
|
321 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
322 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
|
323 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
|
324 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
325 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
|
326 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
|
327 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
|
328 |
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 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
|
330 g_slice_free(PurpleBuddyIcon, icon); |
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 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
333 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
334 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
335 return icon; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
336 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
337 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
338 void |
15823 | 339 purple_buddy_icon_update(PurpleBuddyIcon *icon) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
340 { |
15823 | 341 PurpleConversation *conv; |
342 PurpleAccount *account; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 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
|
344 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
|
345 GSList *buddies; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 g_return_if_fail(icon != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
348 |
15823 | 349 account = purple_buddy_icon_get_account(icon); |
350 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
|
351 |
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
|
352 /* 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
|
353 * 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
|
354 * 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
|
355 * 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
|
356 * 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
|
357 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
|
358 |
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
|
359 /* 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
|
360 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
|
361 |
16817
10f175539cfe
Change a few functions to free a linked list while iterating through
Mark Doliner <mark@kingant.net>
parents:
16710
diff
changeset
|
362 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
|
363 while (buddies != NULL) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
364 { |
16817
10f175539cfe
Change a few functions to free a linked list while iterating through
Mark Doliner <mark@kingant.net>
parents:
16710
diff
changeset
|
365 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
|
366 char *old_icon; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
367 |
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
|
368 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
|
369 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
|
370 "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
|
371 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
|
372 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
373 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
|
374 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
|
375 "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
|
376 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
|
377 |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
378 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
|
379 { |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
380 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
|
381 "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
|
382 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
|
383 } |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
384 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
|
385 { |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
386 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
|
387 "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
|
388 } |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
389 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
|
390 } |
16981
a520e48dbfef
Patch from ticket #819 from vampire
Richard Laager <rlaager@wiktel.com>
parents:
16879
diff
changeset
|
391 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
|
392 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
393 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
|
394 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
|
395 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
396 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
|
397 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
|
398 |
10f175539cfe
Change a few functions to free a linked list while iterating through
Mark Doliner <mark@kingant.net>
parents:
16710
diff
changeset
|
399 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
|
400 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 |
15823 | 402 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
|
403 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
404 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
|
405 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
|
406 |
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
|
407 /* 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
|
408 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
|
409 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 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
|
412 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
|
413 size_t len, const char *checksum) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
414 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
415 PurpleStoredImage *old_img; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
416 |
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
|
417 g_return_if_fail(icon != NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
418 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
419 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
|
420 icon->img = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 |
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
|
422 if (data != NULL) |
16482
3be560001d26
Kill some compiler warnings and TODOs of mine.
Richard Laager <rlaager@wiktel.com>
parents:
16391
diff
changeset
|
423 { |
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
|
424 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
|
425 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
|
426 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
|
427 g_free(data); |
16482
3be560001d26
Kill some compiler warnings and TODOs of mine.
Richard Laager <rlaager@wiktel.com>
parents:
16391
diff
changeset
|
428 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
429 |
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
|
430 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
|
431 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
|
432 |
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
|
433 purple_buddy_icon_update(icon); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
434 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
435 purple_imgstore_unref(old_img); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
436 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
437 |
15823 | 438 PurpleAccount * |
439 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
|
440 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
441 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
|
442 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
443 return icon->account; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
444 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
445 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
446 const char * |
15823 | 447 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
|
448 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
449 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
|
450 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
451 return icon->username; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
452 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
453 |
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
|
454 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
|
455 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
|
456 { |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
457 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
|
458 |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
459 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
|
460 } |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
461 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
462 gconstpointer |
15823 | 463 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
|
464 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
465 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
|
466 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
467 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
|
468 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
469 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
|
470 *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
|
471 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
472 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
|
473 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
474 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
475 return NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
476 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
477 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
478 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
|
479 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
|
480 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
481 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
|
482 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
|
483 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
484 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
485 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
486 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
487 void |
15823 | 488 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
|
489 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
|
490 const char *checksum) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
491 { |
16828
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
492 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
|
493 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
|
494 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
495 g_return_if_fail(account != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
496 g_return_if_fail(username != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
497 |
16828
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
498 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
|
499 |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
500 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
|
501 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
|
502 |
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
|
503 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
|
504 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
|
505 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
|
506 { |
16828
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
507 if (icon_data != NULL && icon_len > 0) |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
508 { |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
509 PurpleBuddyIcon *icon = purple_buddy_icon_new(account, username, icon_data, icon_len, checksum); |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
510 |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
511 /* purple_buddy_icon_new() calls |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
512 * purple_buddy_icon_set_data(), which calls |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
513 * purple_buddy_icon_update(), which has the buddy list |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
514 * and conversations take references as appropriate. |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
515 * This function doesn't return icon, so we can't |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
516 * leave a reference dangling. */ |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
517 purple_buddy_icon_unref(icon); |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
518 } |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
519 else |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
520 { |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
521 /* If the buddy list or a conversation was holding a |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
522 * reference, we'd have found the icon in the cache. |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
523 * Since we know we're deleting the icon, we only |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
524 * need a subset of purple_buddy_icon_update(). */ |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
525 |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
526 GSList *buddies = purple_find_buddies(account, username); |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
527 while (buddies != NULL) |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
528 { |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
529 PurpleBuddy *buddy = (PurpleBuddy *)buddies->data; |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
530 |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
531 unref_filename(purple_blist_node_get_string((PurpleBlistNode *)buddy, "buddy_icon")); |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
532 purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "buddy_icon"); |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
533 purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "icon_checksum"); |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
534 |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
535 buddies = g_slist_delete_link(buddies, buddies); |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
536 } |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
537 |
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
538 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
539 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
540 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
541 |
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
|
542 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
|
543 { |
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
|
544 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
|
545 |
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
|
546 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
|
547 |
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
|
548 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
|
549 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
|
550 |
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
|
551 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
|
552 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
|
553 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
|
554 { |
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
|
555 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
|
556 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
|
557 } |
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
|
558 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
|
559 } |
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
|
560 |
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
|
561 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
|
562 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
|
563 { |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
564 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
|
565 "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
|
566 } |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
567 |
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
|
568 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
|
569 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
|
570 { |
16384
54ea8863b8e8
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@wiktel.com>
parents:
16383
diff
changeset
|
571 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
|
572 |
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
|
573 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
|
574 { |
16384
54ea8863b8e8
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@wiktel.com>
parents:
16383
diff
changeset
|
575 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
|
576 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
|
577 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
|
578 |
16384
54ea8863b8e8
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@wiktel.com>
parents:
16383
diff
changeset
|
579 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
|
580 } |
16384
54ea8863b8e8
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@wiktel.com>
parents:
16383
diff
changeset
|
581 |
54ea8863b8e8
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@wiktel.com>
parents:
16383
diff
changeset
|
582 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
|
583 } |
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 |
15823 | 585 PurpleBuddyIcon * |
586 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
|
587 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
588 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
|
589 PurpleBuddyIcon *icon = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
590 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
591 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
|
592 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
|
593 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
594 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
|
595 |
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
|
596 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
|
597 { |
15823 | 598 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
|
599 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
|
600 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
|
601 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
|
602 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
|
603 size_t len; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
604 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
605 if (!b) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
606 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
607 |
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
|
608 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
|
609 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
610 if (protocol_icon_file == NULL) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
611 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
612 |
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 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
|
614 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
615 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
|
616 /* 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
|
617 * 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
|
618 * 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
|
619 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
|
620 |
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 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
|
622 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
623 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
|
624 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
|
625 { |
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
|
626 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
|
627 |
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
|
628 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
|
629 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
|
630 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
|
631 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
|
632 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
633 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
|
634 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
635 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
636 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
|
637 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
638 |
16828
56823a55581a
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@wiktel.com>
parents:
16817
diff
changeset
|
639 return purple_buddy_icon_ref(icon); |
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
|
640 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
641 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
642 gboolean |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
643 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
|
644 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
645 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
|
646 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
647 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
|
648 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
649 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
650 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
|
651 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
|
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 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
|
654 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
|
655 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
|
656 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
|
657 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
|
658 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
|
659 |
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 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
|
661 |
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 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
|
663 { |
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 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
|
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 |
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 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
|
668 |
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 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
|
670 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
|
671 |
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 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
|
673 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
|
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 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
|
676 { |
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 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
|
678 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
|
679 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
|
680 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
|
681 } |
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 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
|
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 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
|
685 } |
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 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
|
688 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
|
689 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
|
690 { |
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 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
|
692 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
|
693 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
|
694 |
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
|
695 old_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
|
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 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
|
698 { |
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
|
699 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
|
700 } |
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
|
701 |
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
|
702 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
|
703 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
|
704 { |
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 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
|
706 purple_account_set_string(account, "buddy_icon", filename); |
16621
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
707 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
|
708 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
|
709 } |
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
|
710 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
|
711 { |
16482
3be560001d26
Kill some compiler warnings and TODOs of mine.
Richard Laager <rlaager@wiktel.com>
parents:
16391
diff
changeset
|
712 purple_account_set_string(account, "buddy_icon", NULL); |
16621
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
713 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
|
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 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
|
716 |
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 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
|
718 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
|
719 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
|
720 g_hash_table_remove(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
|
721 |
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 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
|
723 { |
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 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
|
725 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
|
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 gc = purple_account_get_connection(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
|
728 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 |
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
|
730 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
|
731 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
|
732 } |
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
|
733 |
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
|
734 if (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
|
735 purple_imgstore_unref(old_img); |
16616
4eb08fcc16d8
Fix assertion when creating a new account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
16596
diff
changeset
|
736 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
|
737 { |
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
|
738 /* 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
|
739 * 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
|
740 * 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
|
741 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
|
742 } |
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
|
743 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
|
744 |
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
|
745 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
|
746 } |
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
|
747 |
16621
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
748 time_t |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
749 purple_buddy_icons_get_account_icon_timestamp(PurpleAccount *account) |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
750 { |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
751 time_t ret; |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
752 |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
753 g_return_val_if_fail(account != NULL, 0); |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
754 |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
755 ret = purple_account_get_int(account, "buddy_icon_timestamp", 0); |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
756 |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
757 /* This deals with migration cases. */ |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
758 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
|
759 { |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
760 ret = time(NULL); |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
761 purple_account_set_int(account, "buddy_icon_timestamp", ret); |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
762 } |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
763 |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
764 return ret; |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
765 } |
dbd0a01a9a81
The OSCAR timestamp stuff.
Richard Laager <rlaager@wiktel.com>
parents:
16611
diff
changeset
|
766 |
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
|
767 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
|
768 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
|
769 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
770 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
|
771 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
|
772 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
|
773 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
|
774 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
|
775 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
|
776 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
777 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
|
778 |
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
|
779 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
|
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 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
|
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 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
784 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
|
785 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
786 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
|
787 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
|
788 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
789 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
|
790 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
|
791 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
792 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
|
793 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
794 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
|
795 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
|
796 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
|
797 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
|
798 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
799 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
|
800 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
801 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
|
802 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
803 |
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
|
804 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
|
805 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
|
806 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
|
807 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
808 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
|
809 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
|
810 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
|
811 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
|
812 |
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
|
813 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
|
814 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
815 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
|
816 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
817 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
|
818 } |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
819 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
820 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
|
821 "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
|
822 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
|
823 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
824 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
|
825 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
|
826 "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
|
827 filename); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
828 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
|
829 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
830 else |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
831 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
832 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
|
833 "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
|
834 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
835 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
|
836 |
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
|
837 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
|
838 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
|
839 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
|
840 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
|
841 |
16381
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
842 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
|
843 { |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
844 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
|
845 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
|
846 |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
847 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
|
848 continue; |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
849 |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
850 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
|
851 |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
852 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
|
853 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
|
854 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
|
855 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
|
856 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
|
857 |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
858 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
|
859 } |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
860 |
16385
a0df0eb75e1b
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@wiktel.com>
parents:
16384
diff
changeset
|
861 if (old_img) |
a0df0eb75e1b
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@wiktel.com>
parents:
16384
diff
changeset
|
862 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
|
863 else if (old_icon) |
16385
a0df0eb75e1b
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@wiktel.com>
parents:
16384
diff
changeset
|
864 { |
a0df0eb75e1b
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@wiktel.com>
parents:
16384
diff
changeset
|
865 /* 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
|
866 * 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
|
867 * 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
|
868 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
|
869 } |
a0df0eb75e1b
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@wiktel.com>
parents:
16384
diff
changeset
|
870 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
|
871 |
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
|
872 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
|
873 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
874 |
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
|
875 void |
16637
250623ba4218
The GNOME coding guidelines recommend prefixing internal symbols with an underscore.
Richard Laager <rlaager@wiktel.com>
parents:
16631
diff
changeset
|
876 _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
|
877 { |
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 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
|
879 } |
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 static void |
16551
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
882 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
|
883 { |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
884 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
|
885 |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
886 if (!strcmp(setting_name, "buddy_icon")) |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
887 { |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
888 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
|
889 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
|
890 } |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
891 } |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
892 |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
893 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
|
894 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
|
895 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
|
896 { |
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 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
|
898 |
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 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
|
900 { |
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 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
|
902 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
|
903 { |
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 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
|
905 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
|
906 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
907 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
|
908 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
909 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
|
910 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
911 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
|
912 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
|
913 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
914 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
|
915 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
916 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
|
917 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
|
918 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
|
919 char *new_filename; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
920 |
16629
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
921 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
|
922 { |
16629
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
923 g_free(path); |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
924 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
|
925 return; |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
926 } |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
927 |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
928 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
|
929 { |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
930 /* 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
|
931 * 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
|
932 * 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
|
933 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
|
934 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
|
935 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
|
936 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
|
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 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
939 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
|
940 |
18039
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
16981
diff
changeset
|
941 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
|
942 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
|
943 { |
16629
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
944 purple_debug_error("buddyicon", |
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
945 "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
|
946 "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
|
947 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
|
948 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
|
949 } |
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 |
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 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
|
952 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
|
953 { |
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 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
|
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 purple_debug_error("buddyicon", "Error writing %s: %s\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
|
957 path, strerror(errno)); |
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 } |
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 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
|
960 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
|
961 |
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 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
|
963 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
964 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
|
965 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
966 purple_debug_error("buddyicon", "Unable to create file %s: %s\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
|
967 path, strerror(errno)); |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
968 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
|
969 g_free(path); |
16551
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
970 |
175eadaead53
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@wiktel.com>
parents:
16537
diff
changeset
|
971 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
|
972 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
|
973 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
974 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
|
975 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
976 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
|
977 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
|
978 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
|
979 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
|
980 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
981 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
|
982 |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
983 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
|
984 { |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
985 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
|
986 |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
987 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
|
988 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
|
989 { |
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 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
|
991 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
|
992 } |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
993 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
|
994 { |
16569
d212880d8d5b
Make this yahoo hack compile.
Richard Laager <rlaager@wiktel.com>
parents:
16568
diff
changeset
|
995 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
|
996 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
|
997 |
8cd67084833c
In theory, this solves the massive pile of g_log errors that occur when
Richard Laager <rlaager@wiktel.com>
parents:
16553
diff
changeset
|
998 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
|
999 { |
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
|
1000 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
|
1001 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
|
1002 { |
8cd67084833c
In theory, this solves the massive pile of g_log errors that occur when
Richard Laager <rlaager@wiktel.com>
parents:
16553
diff
changeset
|
1003 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
|
1004 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
|
1005 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
|
1006 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
|
1007 } |
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
|
1008 } |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
1009 } |
e0c9a46b459f
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@wiktel.com>
parents:
16385
diff
changeset
|
1010 } |
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
|
1011 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1012 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
|
1013 { |
16629
898019538f44
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@wiktel.com>
parents:
16628
diff
changeset
|
1014 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
|
1015 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
|
1016 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
|
1017 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1018 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1019 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1020 void |
16637
250623ba4218
The GNOME coding guidelines recommend prefixing internal symbols with an underscore.
Richard Laager <rlaager@wiktel.com>
parents:
16631
diff
changeset
|
1021 _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
|
1022 { |
16508
c8bc8048f264
This is probably needed to compile.
Richard Laager <rlaager@wiktel.com>
parents:
16506
diff
changeset
|
1023 const char *dirname = purple_buddy_icons_get_cache_dir(); |
18063
926ccb104da0
disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents:
18058
diff
changeset
|
1024 GList *cur; |
16505
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 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
|
1027 { |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1028 PurpleAccount *account = cur->data; |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1029 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
|
1030 |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1031 if (account_icon_file != NULL) |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1032 { |
16510
c01528418cc2
I really shouldn't commit before compiling.
Richard Laager <rlaager@wiktel.com>
parents:
16508
diff
changeset
|
1033 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
|
1034 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
|
1035 { |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1036 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
|
1037 } else { |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1038 ref_filename(account_icon_file); |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1039 } |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1040 g_free(path); |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1041 } |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1042 } |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1043 } |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1044 |
1d1ddf972ac8
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@wiktel.com>
parents:
16482
diff
changeset
|
1045 void |
16637
250623ba4218
The GNOME coding guidelines recommend prefixing internal symbols with an underscore.
Richard Laager <rlaager@wiktel.com>
parents:
16631
diff
changeset
|
1046 _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
|
1047 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1048 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
|
1049 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
|
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 /* 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
|
1052 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
|
1053 { |
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 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
|
1055 { |
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 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
|
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 (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
|
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 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
|
1061 "Unable to create directory %s: %s\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
|
1062 dirname, strerror(errno)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1063 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1064 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1065 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1066 |
16596
63a1de71e389
Whitespace fix from patch in ticket #383
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16569
diff
changeset
|
1067 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
|
1068 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1069 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
|
1070 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1071 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
|
1072 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1073 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
|
1074 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
|
1075 { |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1076 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
|
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 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
|
1079 "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
|
1080 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
|
1081 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1082 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
|
1083 { |
16381
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
1084 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
|
1085 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
|
1086 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1087 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
|
1088 "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
|
1089 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
|
1090 "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
|
1091 } |
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
|
1092 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
|
1093 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
|
1094 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
|
1095 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1096 } |
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 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
|
1099 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1100 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
|
1101 |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1102 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
|
1103 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
|
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 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
|
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 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
|
1108 "custom_buddy_icon", |
16552
e98cd6ed5c13
Minor whitespace tweak.
Richard Laager <rlaager@wiktel.com>
parents:
16551
diff
changeset
|
1109 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
|
1110 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1111 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
|
1112 { |
16381
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16378
diff
changeset
|
1113 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
|
1114 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
|
1115 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1116 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
|
1117 "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
|
1118 } |
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
|
1119 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
|
1120 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
|
1121 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
|
1122 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1123 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1124 } |
c9b4ff420140
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
1125 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
|
1126 } |
15374
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1129 void |
15823 | 1130 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
|
1131 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1132 icon_caching = caching; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1133 } |
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 gboolean |
15823 | 1136 purple_buddy_icons_is_caching(void) |
15374
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 return icon_caching; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1139 } |
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 void |
15823 | 1142 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
|
1143 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1144 g_return_if_fail(dir != NULL); |
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 g_free(cache_dir); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1147 cache_dir = g_strdup(dir); |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1150 const char * |
15823 | 1151 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
|
1152 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1153 return cache_dir; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1154 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1155 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1156 void * |
15823 | 1157 purple_buddy_icons_get_handle() |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1158 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1159 static int handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1160 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1161 return &handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1162 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1163 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1164 void |
15823 | 1165 purple_buddy_icons_init() |
15374
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 account_cache = g_hash_table_new_full( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1168 g_direct_hash, g_direct_equal, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1169 NULL, (GFreeFunc)g_hash_table_destroy); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1170 |
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
|
1171 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
|
1172 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
|
1173 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
|
1174 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
|
1175 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
|
1176 |
15823 | 1177 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
|
1178 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1179 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
|
1180 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
|
1181 G_CALLBACK(image_deleting_cb), NULL); |
15374
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1184 void |
15823 | 1185 purple_buddy_icons_uninit() |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1186 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16373
diff
changeset
|
1187 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
|
1188 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1189 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
|
1190 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
|
1191 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
|
1192 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
|
1193 g_free(old_icons_dir); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1194 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1195 |
15823 | 1196 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
|
1197 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1198 int new_width, new_height; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1199 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1200 new_width = *width; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1201 new_height = *height; |
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 if (*width < spec->min_width) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1204 new_width = spec->min_width; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1205 else if (*width > spec->max_width) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1206 new_width = spec->max_width; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1207 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1208 if (*height < spec->min_height) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1209 new_height = spec->min_height; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1210 else if (*height > spec->max_height) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1211 new_height = spec->max_height; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1212 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1213 /* preserve aspect ratio */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1214 if ((double)*height * (double)new_width > |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1215 (double)*width * (double)new_height) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1216 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
|
1217 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1218 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
|
1219 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1220 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1221 *width = new_width; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1222 *height = new_height; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1223 } |