Wed, 25 Apr 2007 22:23:29 +0000
Change the imgstore and by extension, then the buddy icon code to take over
the references to icon data instead of calling g_memdup(). This eliminates
g_memdup()ing and g_free()ing in ~50% of the callers. For the rest, it's no
worse (they now do a g_memdup() instead of the core) and they may be able to
be modified in the future to avoid that.
| 6846 | 1 | /** |
| 2 | * @file icon.c Buddy Icon API | |
| 3 | * @ingroup core | |
| 4 | * | |
| 15884 | 5 | * purple |
| 6846 | 6 | * |
| 15884 | 7 | * Purple is the legal property of its developers, whose names are too numerous |
| 8046 | 8 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 9 | * source distribution. | |
| 6846 | 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify | |
| 12 | * it under the terms of the GNU General Public License as published by | |
| 13 | * the Free Software Foundation; either version 2 of the License, or | |
| 14 | * (at your option) any later version. | |
| 15 | * | |
| 16 | * This program is distributed in the hope that it will be useful, | |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 | * GNU General Public License for more details. | |
| 20 | * | |
| 21 | * You should have received a copy of the GNU General Public License | |
| 22 | * along with this program; if not, write to the Free Software | |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 24 | */ | |
| 25 | #include "internal.h" | |
| 26 | #include "buddyicon.h" | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
27 | #include "cipher.h" |
| 6846 | 28 | #include "conversation.h" |
|
13555
b4d6a5e6853a
[gaim-migrate @ 15932]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12996
diff
changeset
|
29 | #include "dbus-maybe.h" |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
30 | #include "debug.h" |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
31 | #include "imgstore.h" |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
32 | #include "util.h" |
| 6846 | 33 | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
34 | typedef struct _PurpleBuddyIconData PurpleBuddyIconData; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
35 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
36 | /* NOTE: Instances of this struct are allocated without zeroing the memory, so |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
37 | * NOTE: be sure to update purple_buddy_icon_new() if you add members. */ |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
38 | struct _PurpleBuddyIcon |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
39 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
40 | PurpleAccount *account; /**< The account the user is on. */ |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
41 | PurpleStoredImage *img; /**< The id of the stored image with the |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
42 | the icon data. */ |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
43 | char *username; /**< The username the icon belongs to. */ |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
44 | char *checksum; /**< The protocol checksum. */ |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
45 | int ref_count; /**< The buddy icon reference count. */ |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
46 | }; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
47 | |
| 6846 | 48 | static GHashTable *account_cache = NULL; |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
49 | static GHashTable *icon_data_cache = NULL; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
50 | static GHashTable *icon_file_cache = NULL; |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
51 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
52 | /* This one is used for both custom buddy icons |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
53 | * on PurpleContacts and account icons. */ |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
54 | static GHashTable *pointer_icon_cache = NULL; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
55 | |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
56 | static char *cache_dir = NULL; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
57 | static gboolean icon_caching = TRUE; |
| 6846 | 58 | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
59 | /* For ~/.gaim to ~/.purple migration. */ |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
60 | static char *old_icons_dir = NULL; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
61 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
62 | static void |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
63 | ref_filename(const char *filename) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
64 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
65 | int refs; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
66 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
67 | g_return_if_fail(filename != NULL); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
68 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
69 | refs = GPOINTER_TO_INT(g_hash_table_lookup(icon_file_cache, filename)); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
70 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
71 | g_hash_table_insert(icon_file_cache, g_strdup(filename), |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
72 | GINT_TO_POINTER(refs + 1)); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
73 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
74 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
75 | static void |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
76 | unref_filename(const char *filename) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
77 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
78 | int refs; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
79 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
80 | if (filename == NULL) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
81 | return; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
82 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
83 | refs = GPOINTER_TO_INT(g_hash_table_lookup(icon_file_cache, filename)); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
84 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
85 | if (refs == 1) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
86 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
87 | g_hash_table_remove(icon_file_cache, filename); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
88 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
89 | else |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
90 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
91 | g_hash_table_insert(icon_file_cache, g_strdup(filename), |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
92 | GINT_TO_POINTER(refs - 1)); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
93 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
94 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
95 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
96 | static char * |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
97 | purple_buddy_icon_data_calculate_filename(guchar *icon_data, size_t icon_len) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
98 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
99 | PurpleCipherContext *context; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
100 | gchar digest[41]; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
101 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
102 | context = purple_cipher_context_new_by_name("sha1", NULL); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
103 | if (context == NULL) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
104 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
105 | purple_debug_error("buddyicon", "Could not find sha1 cipher\n"); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
106 | g_return_val_if_reached(NULL); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
107 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
108 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
109 | /* Hash the icon data */ |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
110 | purple_cipher_context_append(context, icon_data, icon_len); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
111 | if (!purple_cipher_context_digest_to_str(context, sizeof(digest), digest, NULL)) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
112 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
113 | purple_debug_error("buddyicon", "Failed to get SHA-1 digest.\n"); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
114 | g_return_val_if_reached(NULL); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
115 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
116 | purple_cipher_context_destroy(context); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
117 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
118 | /* Return the filename */ |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
119 | return g_strdup_printf("%s.%s", digest, |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
120 | purple_util_get_image_extension(icon_data, icon_len)); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
121 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
122 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
123 | static void |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
124 | purple_buddy_icon_data_cache(PurpleStoredImage *img) |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
125 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
126 | const char *dirname; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
127 | char *path; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
128 | FILE *file = NULL; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
129 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
130 | g_return_if_fail(img != NULL); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
131 | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
132 | if (!purple_buddy_icons_is_caching()) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
133 | return; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
134 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
135 | dirname = purple_buddy_icons_get_cache_dir(); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
136 | path = g_build_filename(dirname, purple_imgstore_get_filename(img), NULL); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
137 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
138 | if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
139 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
140 | purple_debug_info("buddyicon", "Creating icon cache directory.\n"); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
141 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
142 | if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
143 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
144 | purple_debug_error("buddyicon", |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
145 | "Unable to create directory %s: %s\n", |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
146 | dirname, strerror(errno)); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
147 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
148 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
149 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
150 | if ((file = g_fopen(path, "wb")) != NULL) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
151 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
152 | if (!fwrite(purple_imgstore_get_data(img), purple_imgstore_get_size(img), 1, file)) |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
153 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
154 | purple_debug_error("buddyicon", "Error writing %s: %s\n", |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
155 | path, strerror(errno)); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
156 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
157 | else |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
158 | purple_debug_info("buddyicon", "Wrote cache file: %s\n", path); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
159 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
160 | fclose(file); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
161 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
162 | else |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
163 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
164 | purple_debug_error("buddyicon", "Unable to create file %s: %s\n", |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
165 | path, strerror(errno)); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
166 | g_free(path); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
167 | return; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
168 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
169 | g_free(path); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
170 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
171 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
172 | static void |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
173 | purple_buddy_icon_data_uncache_file(const char *filename) |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
174 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
175 | const char *dirname; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
176 | char *path; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
177 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
178 | g_return_if_fail(filename != NULL); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
179 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
180 | /* It's possible that there are other references to this icon |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
181 | * cache file that are not currently loaded into memory. */ |
|
16438
64e892ac6180
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
182 | if (GPOINTER_TO_INT(g_hash_table_lookup(icon_file_cache, filename))) |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
183 | return; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
184 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
185 | dirname = purple_buddy_icons_get_cache_dir(); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
186 | path = g_build_filename(dirname, filename, NULL); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
187 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
188 | if (g_file_test(path, G_FILE_TEST_EXISTS)) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
189 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
190 | if (g_unlink(path)) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
191 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
192 | purple_debug_error("buddyicon", "Failed to delete %s: %s\n", |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
193 | path, strerror(errno)); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
194 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
195 | else |
|
16438
64e892ac6180
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
196 | { |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
197 | purple_debug_info("buddyicon", "Deleted cache file: %s\n", path); |
|
16438
64e892ac6180
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
198 | } |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
199 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
200 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
201 | g_free(path); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
202 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
203 | |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
204 | static gboolean |
|
16531
98363f6cdc6c
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@pidgin.im>
parents:
16446
diff
changeset
|
205 | value_equals(gpointer key, gpointer value, gpointer user_data) |
|
98363f6cdc6c
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@pidgin.im>
parents:
16446
diff
changeset
|
206 | { |
|
98363f6cdc6c
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@pidgin.im>
parents:
16446
diff
changeset
|
207 | return (value == user_data); |
|
98363f6cdc6c
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@pidgin.im>
parents:
16446
diff
changeset
|
208 | } |
|
98363f6cdc6c
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@pidgin.im>
parents:
16446
diff
changeset
|
209 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
210 | static void |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
211 | image_deleting_cb(PurpleStoredImage *img, gpointer data) |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
212 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
213 | const char *filename = purple_imgstore_get_filename(img); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
214 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
215 | if (img == g_hash_table_lookup(icon_data_cache, filename)) |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
216 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
217 | purple_buddy_icon_data_uncache_file(filename); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
218 | g_hash_table_remove(icon_data_cache, filename); |
|
16531
98363f6cdc6c
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@pidgin.im>
parents:
16446
diff
changeset
|
219 | |
|
98363f6cdc6c
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@pidgin.im>
parents:
16446
diff
changeset
|
220 | /* We could make this O(1) by using another hash table, but |
|
98363f6cdc6c
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@pidgin.im>
parents:
16446
diff
changeset
|
221 | * this is probably good enough. */ |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
222 | g_hash_table_foreach_remove(pointer_icon_cache, value_equals, img); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
223 | } |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
224 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
225 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
226 | static PurpleStoredImage * |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
227 | purple_buddy_icon_data_new(guchar *icon_data, size_t icon_len, const char *filename) |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
228 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
229 | char *file; |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
230 | PurpleStoredImage *img; |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
231 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
232 | g_return_val_if_fail(icon_data != NULL, NULL); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
233 | g_return_val_if_fail(icon_len > 0, NULL); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
234 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
235 | if (filename == NULL) |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
236 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
237 | file = purple_buddy_icon_data_calculate_filename(icon_data, icon_len); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
238 | if (file == NULL) |
|
16539
75a20ae3a527
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@pidgin.im>
parents:
16538
diff
changeset
|
239 | { |
|
75a20ae3a527
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@pidgin.im>
parents:
16538
diff
changeset
|
240 | g_free(icon_data); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
241 | return NULL; |
|
16539
75a20ae3a527
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@pidgin.im>
parents:
16538
diff
changeset
|
242 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
243 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
244 | else |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
245 | file = g_strdup(filename); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
246 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
247 | if ((img = g_hash_table_lookup(icon_data_cache, file))) |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
248 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
249 | g_free(file); |
|
16539
75a20ae3a527
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@pidgin.im>
parents:
16538
diff
changeset
|
250 | g_free(icon_data); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
251 | return purple_imgstore_ref(img); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
252 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
253 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
254 | img = purple_imgstore_add(icon_data, icon_len, file); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
255 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
256 | /* This will take ownership of file and g_free it either now or later. */ |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
257 | g_hash_table_insert(icon_data_cache, file, img); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
258 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
259 | purple_buddy_icon_data_cache(img); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
260 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
261 | return img; |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
262 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
263 | |
| 15884 | 264 | static PurpleBuddyIcon * |
| 265 | purple_buddy_icon_create(PurpleAccount *account, const char *username) | |
| 9396 | 266 | { |
| 15884 | 267 | PurpleBuddyIcon *icon; |
| 9396 | 268 | GHashTable *icon_cache; |
| 269 | ||
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
270 | /* This does not zero. See purple_buddy_icon_new() for |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
271 | * information on which function allocates which member. */ |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
272 | icon = g_slice_new(PurpleBuddyIcon); |
| 15884 | 273 | PURPLE_DBUS_REGISTER_POINTER(icon, PurpleBuddyIcon); |
| 9396 | 274 | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
275 | icon->account = account; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
276 | icon->username = g_strdup(username); |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
277 | icon->checksum = NULL; |
| 9396 | 278 | |
| 279 | icon_cache = g_hash_table_lookup(account_cache, account); | |
| 280 | ||
| 281 | if (icon_cache == NULL) | |
| 282 | { | |
| 283 | icon_cache = g_hash_table_new(g_str_hash, g_str_equal); | |
| 284 | ||
| 285 | g_hash_table_insert(account_cache, account, icon_cache); | |
| 286 | } | |
| 287 | ||
| 288 | g_hash_table_insert(icon_cache, | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
289 | (char *)purple_buddy_icon_get_username(icon), icon); |
| 9396 | 290 | return icon; |
| 291 | } | |
| 292 | ||
| 15884 | 293 | PurpleBuddyIcon * |
| 294 | purple_buddy_icon_new(PurpleAccount *account, const char *username, | |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
295 | void *icon_data, size_t icon_len, |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
296 | const char *checksum) |
| 6846 | 297 | { |
| 15884 | 298 | PurpleBuddyIcon *icon; |
| 6846 | 299 | |
| 300 | g_return_val_if_fail(account != NULL, NULL); | |
| 301 | g_return_val_if_fail(username != NULL, NULL); | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
302 | g_return_val_if_fail(icon_data != NULL, NULL); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
303 | g_return_val_if_fail(icon_len > 0, NULL); |
| 6846 | 304 | |
|
16438
64e892ac6180
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
305 | /* purple_buddy_icons_find() does allocation, so be |
|
64e892ac6180
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
306 | * sure to update it as well when members are added. */ |
| 15884 | 307 | icon = purple_buddy_icons_find(account, username); |
| 6846 | 308 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
309 | /* purple_buddy_icon_create() sets account & username */ |
| 6846 | 310 | if (icon == NULL) |
| 15884 | 311 | icon = purple_buddy_icon_create(account, username); |
| 6846 | 312 | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
313 | /* Take a reference for the caller of this function. */ |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
314 | icon->ref_count = 1; |
| 6846 | 315 | |
|
16438
64e892ac6180
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
316 | /* purple_buddy_icon_set_data() sets img, but it |
|
64e892ac6180
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
317 | * references img first, so we need to initialize it */ |
|
64e892ac6180
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
318 | icon->img = NULL; |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
319 | purple_buddy_icon_set_data(icon, icon_data, icon_len, checksum); |
|
11423
45f4ca09d1d6
[gaim-migrate @ 13660]
Richard Laager <rlaager@pidgin.im>
parents:
11338
diff
changeset
|
320 | |
| 6846 | 321 | return icon; |
| 322 | } | |
| 323 | ||
| 15884 | 324 | PurpleBuddyIcon * |
| 325 | purple_buddy_icon_ref(PurpleBuddyIcon *icon) | |
| 6846 | 326 | { |
| 327 | g_return_val_if_fail(icon != NULL, NULL); | |
| 328 | ||
| 329 | icon->ref_count++; | |
| 330 | ||
| 331 | return icon; | |
| 332 | } | |
| 333 | ||
| 15884 | 334 | PurpleBuddyIcon * |
| 335 | purple_buddy_icon_unref(PurpleBuddyIcon *icon) | |
| 6846 | 336 | { |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
337 | if (icon == NULL) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
338 | return NULL; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
339 | |
|
12250
5b14301dd1ec
[gaim-migrate @ 14552]
Richard Laager <rlaager@pidgin.im>
parents:
12097
diff
changeset
|
340 | g_return_val_if_fail(icon->ref_count > 0, NULL); |
| 6846 | 341 | |
| 342 | icon->ref_count--; | |
| 343 | ||
| 344 | if (icon->ref_count == 0) | |
| 345 | { | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
346 | GHashTable *icon_cache = g_hash_table_lookup(account_cache, purple_buddy_icon_get_account(icon)); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
347 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
348 | if (icon_cache != NULL) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
349 | g_hash_table_remove(icon_cache, purple_buddy_icon_get_username(icon)); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
350 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
351 | g_free(icon->username); |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
352 | g_free(icon->checksum); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
353 | purple_imgstore_unref(icon->img); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
354 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
355 | PURPLE_DBUS_UNREGISTER_POINTER(icon); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
356 | g_slice_free(PurpleBuddyIcon, icon); |
| 6846 | 357 | |
| 358 | return NULL; | |
| 359 | } | |
| 360 | ||
| 361 | return icon; | |
| 362 | } | |
| 363 | ||
| 364 | void | |
| 15884 | 365 | purple_buddy_icon_update(PurpleBuddyIcon *icon) |
| 6846 | 366 | { |
| 15884 | 367 | PurpleConversation *conv; |
| 368 | PurpleAccount *account; | |
| 6846 | 369 | const char *username; |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
370 | PurpleBuddyIcon *icon_to_set; |
| 8550 | 371 | GSList *sl, *list; |
| 6846 | 372 | |
| 373 | g_return_if_fail(icon != NULL); | |
| 374 | ||
| 15884 | 375 | account = purple_buddy_icon_get_account(icon); |
| 376 | username = purple_buddy_icon_get_username(icon); | |
| 6846 | 377 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
378 | /* If no data exists, then call the functions below with NULL to |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
379 | * unset the icon. They will then unref the icon and it should be |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
380 | * destroyed. The only way it wouldn't be destroyed is if someone |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
381 | * else is holding a reference to it, in which case they can kill |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
382 | * the icon when they realize it has no data. */ |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
383 | icon_to_set = icon->img ? icon : NULL; |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
384 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
385 | for (list = sl = purple_find_buddies(account, username); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
386 | sl != NULL; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
387 | sl = sl->next) |
| 6846 | 388 | { |
| 15884 | 389 | PurpleBuddy *buddy = (PurpleBuddy *)sl->data; |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
390 | char *old_icon; |
| 6846 | 391 | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
392 | purple_buddy_set_icon(buddy, icon_to_set); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
393 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
394 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
395 | old_icon = g_strdup(purple_blist_node_get_string((PurpleBlistNode *)buddy, |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
396 | "buddy_icon")); |
|
16440
d4e3c52ce58b
If we're not caching icons, then don't save the filename.
Richard Laager <rlaager@pidgin.im>
parents:
16439
diff
changeset
|
397 | if (icon->img && purple_buddy_icons_is_caching()) |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
398 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
399 | const char *filename = purple_imgstore_get_filename(icon->img); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
400 | purple_blist_node_set_string((PurpleBlistNode *)buddy, |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
401 | "buddy_icon", |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
402 | filename); |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
403 | |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
404 | if (icon->checksum && *icon->checksum) |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
405 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
406 | purple_blist_node_set_string((PurpleBlistNode *)buddy, |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
407 | "icon_checksum", |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
408 | icon->checksum); |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
409 | } |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
410 | else |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
411 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
412 | purple_blist_node_remove_setting((PurpleBlistNode *)buddy, |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
413 | "icon_checksum"); |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
414 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
415 | ref_filename(filename); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
416 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
417 | else |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
418 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
419 | purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "buddy_icon"); |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
420 | purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "icon_checksum"); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
421 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
422 | unref_filename(old_icon); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
423 | g_free(old_icon); |
| 6846 | 424 | } |
| 425 | ||
| 8550 | 426 | g_slist_free(list); |
| 427 | ||
| 15884 | 428 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, username, account); |
| 6846 | 429 | |
|
10246
aa5bff72f94c
[gaim-migrate @ 11386]
Mark Doliner <markdoliner@pidgin.im>
parents:
9801
diff
changeset
|
430 | if (conv != NULL) |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
431 | purple_conv_im_set_icon(PURPLE_CONV_IM(conv), icon_to_set); |
|
11040
37e247d18e78
[gaim-migrate @ 12940]
Richard Laager <rlaager@pidgin.im>
parents:
11033
diff
changeset
|
432 | } |
|
37e247d18e78
[gaim-migrate @ 12940]
Richard Laager <rlaager@pidgin.im>
parents:
11033
diff
changeset
|
433 | |
| 6846 | 434 | void |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
435 | purple_buddy_icon_set_data(PurpleBuddyIcon *icon, guchar *data, |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
436 | size_t len, const char *checksum) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
437 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
438 | PurpleStoredImage *old_img; |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
439 | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
440 | g_return_if_fail(icon != NULL); |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
441 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
442 | old_img = icon->img; |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
443 | icon->img = NULL; |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
444 | |
|
16539
75a20ae3a527
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@pidgin.im>
parents:
16538
diff
changeset
|
445 | if (data != NULL) |
|
75a20ae3a527
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@pidgin.im>
parents:
16538
diff
changeset
|
446 | if (len > 0) |
|
75a20ae3a527
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@pidgin.im>
parents:
16538
diff
changeset
|
447 | icon->img = purple_buddy_icon_data_new(data, len, NULL); |
|
75a20ae3a527
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@pidgin.im>
parents:
16538
diff
changeset
|
448 | else |
|
75a20ae3a527
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@pidgin.im>
parents:
16538
diff
changeset
|
449 | g_free(data); |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
450 | |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
451 | icon->checksum = g_strdup(checksum); |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
452 | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
453 | purple_buddy_icon_update(icon); |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
454 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
455 | purple_imgstore_unref(old_img); |
|
15132
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
456 | } |
|
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
457 | |
| 15884 | 458 | PurpleAccount * |
| 459 | purple_buddy_icon_get_account(const PurpleBuddyIcon *icon) | |
| 6846 | 460 | { |
| 461 | g_return_val_if_fail(icon != NULL, NULL); | |
| 462 | ||
| 463 | return icon->account; | |
| 464 | } | |
| 465 | ||
| 466 | const char * | |
| 15884 | 467 | purple_buddy_icon_get_username(const PurpleBuddyIcon *icon) |
| 6846 | 468 | { |
| 469 | g_return_val_if_fail(icon != NULL, NULL); | |
| 470 | ||
| 471 | return icon->username; | |
| 472 | } | |
| 473 | ||
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
474 | const char * |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
475 | purple_buddy_icon_get_checksum(const PurpleBuddyIcon *icon) |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
476 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
477 | g_return_val_if_fail(icon != NULL, NULL); |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
478 | |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
479 | return icon->checksum; |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
480 | } |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
481 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
482 | gconstpointer |
| 15884 | 483 | purple_buddy_icon_get_data(const PurpleBuddyIcon *icon, size_t *len) |
| 6846 | 484 | { |
| 485 | g_return_val_if_fail(icon != NULL, NULL); | |
| 486 | ||
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
487 | if (icon->img) |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
488 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
489 | if (len != NULL) |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
490 | *len = purple_imgstore_get_size(icon->img); |
| 6846 | 491 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
492 | return purple_imgstore_get_data(icon->img); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
493 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
494 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
495 | return NULL; |
|
15132
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
496 | } |
|
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
497 | |
|
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
498 | const char * |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
499 | purple_buddy_icon_get_extension(const PurpleBuddyIcon *icon) |
|
10953
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
500 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
501 | if (icon->img != NULL) |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
502 | return purple_imgstore_get_extension(icon->img); |
|
10953
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
503 | |
|
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
504 | return NULL; |
|
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
505 | } |
|
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
506 | |
| 6846 | 507 | void |
| 15884 | 508 | purple_buddy_icons_set_for_user(PurpleAccount *account, const char *username, |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
509 | void *icon_data, size_t icon_len, |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
510 | const char *checksum) |
| 6846 | 511 | { |
|
16537
763d885ff7a2
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@pidgin.im>
parents:
16534
diff
changeset
|
512 | PurpleBuddyIcon *icon; |
|
763d885ff7a2
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@pidgin.im>
parents:
16534
diff
changeset
|
513 | |
| 6846 | 514 | g_return_if_fail(account != NULL); |
| 515 | g_return_if_fail(username != NULL); | |
| 516 | ||
|
16537
763d885ff7a2
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@pidgin.im>
parents:
16534
diff
changeset
|
517 | icon = purple_buddy_icons_find(account, username); |
|
9305
63a1b462a208
[gaim-migrate @ 10113]
Christian Hammond <chipx86@chipx86.com>
parents:
9285
diff
changeset
|
518 | |
|
16537
763d885ff7a2
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@pidgin.im>
parents:
16534
diff
changeset
|
519 | if (icon != NULL) |
|
763d885ff7a2
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@pidgin.im>
parents:
16534
diff
changeset
|
520 | purple_buddy_icon_set_data(icon, icon_data, icon_len, checksum); |
|
9305
63a1b462a208
[gaim-migrate @ 10113]
Christian Hammond <chipx86@chipx86.com>
parents:
9285
diff
changeset
|
521 | else |
|
63a1b462a208
[gaim-migrate @ 10113]
Christian Hammond <chipx86@chipx86.com>
parents:
9285
diff
changeset
|
522 | { |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
523 | PurpleBuddyIcon *icon = purple_buddy_icon_new(account, username, icon_data, icon_len, checksum); |
| 15884 | 524 | purple_buddy_icon_unref(icon); |
|
9305
63a1b462a208
[gaim-migrate @ 10113]
Christian Hammond <chipx86@chipx86.com>
parents:
9285
diff
changeset
|
525 | } |
| 6846 | 526 | } |
| 527 | ||
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
528 | char *purple_buddy_icon_get_full_path(PurpleBuddyIcon *icon) |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
529 | { |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
530 | char *path; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
531 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
532 | g_return_val_if_fail(icon != NULL, NULL); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
533 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
534 | if (icon->img == NULL) |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
535 | return NULL; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
536 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
537 | path = g_build_filename(purple_buddy_icons_get_cache_dir(), |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
538 | purple_imgstore_get_filename(icon->img), NULL); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
539 | if (!g_file_test(path, G_FILE_TEST_EXISTS)) |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
540 | { |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
541 | g_free(path); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
542 | return NULL; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
543 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
544 | return path; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
545 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
546 | |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
547 | const char * |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
548 | purple_buddy_icons_get_checksum_for_user(PurpleBuddy *buddy) |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
549 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
550 | return purple_blist_node_get_string((PurpleBlistNode*)buddy, |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
551 | "icon_checksum"); |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
552 | } |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
553 | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
554 | static gboolean |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
555 | read_icon_file(const char *path, guchar **data, size_t *len) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
556 | { |
|
16532
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
557 | GError *err = NULL; |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
558 | |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
559 | if (!g_file_get_contents(path, (gchar **)data, len, &err)) |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
560 | { |
|
16532
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
561 | purple_debug_error("buddyicon", "Error reading %s: %s\n", |
|
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
562 | path, err->message); |
|
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
563 | g_error_free(err); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
564 | |
|
16532
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
565 | return FALSE; |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
566 | } |
|
16532
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
567 | |
|
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
568 | return TRUE; |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
569 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
570 | |
| 15884 | 571 | PurpleBuddyIcon * |
| 572 | purple_buddy_icons_find(PurpleAccount *account, const char *username) | |
| 6846 | 573 | { |
| 574 | GHashTable *icon_cache; | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
575 | PurpleBuddyIcon *icon = NULL; |
| 6846 | 576 | |
| 577 | g_return_val_if_fail(account != NULL, NULL); | |
| 578 | g_return_val_if_fail(username != NULL, NULL); | |
| 579 | ||
| 580 | icon_cache = g_hash_table_lookup(account_cache, account); | |
| 581 | ||
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
582 | if ((icon_cache == NULL) || ((icon = g_hash_table_lookup(icon_cache, username)) == NULL)) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
583 | { |
| 15884 | 584 | PurpleBuddy *b = purple_find_buddy(account, username); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
585 | const char *protocol_icon_file; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
586 | const char *dirname; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
587 | gboolean caching; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
588 | guchar *data; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
589 | size_t len; |
| 9396 | 590 | |
| 591 | if (!b) | |
| 592 | return NULL; | |
| 593 | ||
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
594 | protocol_icon_file = purple_blist_node_get_string((PurpleBlistNode*)b, "buddy_icon"); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
595 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
596 | if (protocol_icon_file == NULL) |
| 9396 | 597 | return NULL; |
| 6846 | 598 | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
599 | dirname = purple_buddy_icons_get_cache_dir(); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
600 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
601 | caching = purple_buddy_icons_is_caching(); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
602 | /* By disabling caching temporarily, we avoid a loop |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
603 | * and don't have to add special code through several |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
604 | * functions. */ |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
605 | purple_buddy_icons_set_caching(FALSE); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
606 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
607 | if (protocol_icon_file != NULL) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
608 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
609 | char *path = g_build_filename(dirname, protocol_icon_file, NULL); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
610 | if (read_icon_file(path, &data, &len)) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
611 | { |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
612 | const char *checksum; |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
613 | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
614 | if (icon == NULL) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
615 | icon = purple_buddy_icon_create(account, username); |
|
16438
64e892ac6180
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
616 | icon->ref_count = 0; |
|
64e892ac6180
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
617 | icon->img = NULL; |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
618 | checksum = g_strdup(purple_blist_node_get_string((PurpleBlistNode*)b, "icon_checksum")); |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
619 | purple_buddy_icon_set_data(icon, data, len, checksum); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
620 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
621 | g_free(path); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
622 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
623 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
624 | purple_buddy_icons_set_caching(caching); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
625 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
626 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
627 | return icon; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
628 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
629 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
630 | gboolean |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
631 | purple_buddy_icons_has_custom_icon(PurpleContact *contact) |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
632 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
633 | g_return_val_if_fail(contact != NULL, FALSE); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
634 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
635 | return (purple_blist_node_get_string((PurpleBlistNode*)contact, "custom_buddy_icon") != NULL); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
636 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
637 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
638 | PurpleStoredImage * |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
639 | purple_buddy_icons_find_account_icon(PurpleAccount *account) |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
640 | { |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
641 | PurpleStoredImage *img; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
642 | const char *account_icon_file; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
643 | const char *dirname; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
644 | char *path; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
645 | guchar *data; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
646 | size_t len; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
647 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
648 | g_return_val_if_fail(account != NULL, NULL); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
649 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
650 | if ((img = g_hash_table_lookup(pointer_icon_cache, account))) |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
651 | { |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
652 | return purple_imgstore_ref(img); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
653 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
654 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
655 | account_icon_file = purple_account_get_string(account, "buddy_icon", NULL); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
656 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
657 | if (account_icon_file == NULL) |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
658 | return NULL; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
659 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
660 | dirname = purple_buddy_icons_get_cache_dir(); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
661 | path = g_build_filename(dirname, account_icon_file, NULL); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
662 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
663 | if (read_icon_file(path, &data, &len)) |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
664 | { |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
665 | g_free(path); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
666 | img = purple_buddy_icon_data_new(data, len, account_icon_file); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
667 | g_hash_table_insert(pointer_icon_cache, account, img); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
668 | return img; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
669 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
670 | g_free(path); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
671 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
672 | return NULL; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
673 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
674 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
675 | PurpleStoredImage * |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
676 | purple_buddy_icons_set_account_icon(PurpleAccount *account, |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
677 | guchar *icon_data, size_t icon_len) |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
678 | { |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
679 | PurpleStoredImage *old_img; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
680 | PurpleStoredImage *img = NULL; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
681 | char *old_icon; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
682 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
683 | old_img = g_hash_table_lookup(pointer_icon_cache, account); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
684 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
685 | if (icon_data != NULL && icon_len > 0) |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
686 | { |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
687 | img = purple_buddy_icon_data_new(icon_data, icon_len, NULL); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
688 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
689 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
690 | old_icon = g_strdup(purple_account_get_string(account, "buddy_icon", NULL)); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
691 | if (img && purple_buddy_icons_is_caching()) |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
692 | { |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
693 | const char *filename = purple_imgstore_get_filename(img); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
694 | purple_account_set_string(account, "buddy_icon", filename); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
695 | ref_filename(filename); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
696 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
697 | else |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
698 | { |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
699 | // TODO |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
700 | // purple_account_remove_setting(account, "buddy_icon"); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
701 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
702 | unref_filename(old_icon); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
703 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
704 | if (img) |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
705 | g_hash_table_insert(pointer_icon_cache, account, img); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
706 | else |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
707 | g_hash_table_remove(pointer_icon_cache, account); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
708 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
709 | if (purple_account_is_connected(account)) |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
710 | { |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
711 | PurpleConnection *gc; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
712 | PurplePluginProtocolInfo *prpl_info; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
713 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
714 | gc = purple_account_get_connection(account); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
715 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
716 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
717 | if (prpl_info && prpl_info->set_buddy_icon) |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
718 | prpl_info->set_buddy_icon(gc, img); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
719 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
720 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
721 | if (old_img) |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
722 | purple_imgstore_unref(old_img); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
723 | else |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
724 | { |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
725 | /* The old icon may not have been loaded into memory. In that |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
726 | * case, we'll need to uncache the filename. The filenames |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
727 | * are ref-counted, so this is safe. */ |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
728 | purple_buddy_icon_data_uncache_file(old_icon); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
729 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
730 | g_free(old_icon); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
731 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
732 | return img; |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
733 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
734 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
735 | PurpleStoredImage * |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
736 | purple_buddy_icons_find_custom_icon(PurpleContact *contact) |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
737 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
738 | PurpleStoredImage *img; |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
739 | const char *custom_icon_file; |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
740 | const char *dirname; |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
741 | char *path; |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
742 | guchar *data; |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
743 | size_t len; |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
744 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
745 | g_return_val_if_fail(contact != NULL, NULL); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
746 | |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
747 | if ((img = g_hash_table_lookup(pointer_icon_cache, contact))) |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
748 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
749 | return purple_imgstore_ref(img); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
750 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
751 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
752 | custom_icon_file = purple_blist_node_get_string((PurpleBlistNode*)contact, "custom_buddy_icon"); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
753 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
754 | if (custom_icon_file == NULL) |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
755 | return NULL; |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
756 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
757 | dirname = purple_buddy_icons_get_cache_dir(); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
758 | path = g_build_filename(dirname, custom_icon_file, NULL); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
759 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
760 | if (read_icon_file(path, &data, &len)) |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
761 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
762 | g_free(path); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
763 | img = purple_buddy_icon_data_new(data, len, custom_icon_file); |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
764 | g_hash_table_insert(pointer_icon_cache, contact, img); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
765 | return img; |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
766 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
767 | g_free(path); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
768 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
769 | return NULL; |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
770 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
771 | |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
772 | PurpleStoredImage * |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
773 | purple_buddy_icons_set_custom_icon(PurpleContact *contact, |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
774 | guchar *icon_data, size_t icon_len) |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
775 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
776 | PurpleStoredImage *old_img; |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
777 | PurpleStoredImage *img = NULL; |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
778 | char *old_icon; |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
779 | PurpleBlistNode *child; |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
780 | |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
781 | old_img = g_hash_table_lookup(pointer_icon_cache, contact); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
782 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
783 | if (icon_data != NULL && icon_len > 0) |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
784 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
785 | img = purple_buddy_icon_data_new(icon_data, icon_len, NULL); |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
786 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
787 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
788 | old_icon = g_strdup(purple_blist_node_get_string((PurpleBlistNode *)contact, |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
789 | "custom_buddy_icon")); |
|
16440
d4e3c52ce58b
If we're not caching icons, then don't save the filename.
Richard Laager <rlaager@pidgin.im>
parents:
16439
diff
changeset
|
790 | if (img && purple_buddy_icons_is_caching()) |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
791 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
792 | const char *filename = purple_imgstore_get_filename(img); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
793 | purple_blist_node_set_string((PurpleBlistNode *)contact, |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
794 | "custom_buddy_icon", |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
795 | filename); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
796 | ref_filename(filename); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
797 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
798 | else |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
799 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
800 | purple_blist_node_remove_setting((PurpleBlistNode *)contact, |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
801 | "custom_buddy_icon"); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
802 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
803 | unref_filename(old_icon); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
804 | |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
805 | if (img) |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
806 | g_hash_table_insert(pointer_icon_cache, contact, img); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
807 | else |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
808 | g_hash_table_remove(pointer_icon_cache, contact); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
809 | |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
810 | for (child = contact->node.child ; child ; child = child->next) |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
811 | { |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
812 | PurpleBuddy *buddy; |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
813 | PurpleConversation *conv; |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
814 | |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
815 | if (!PURPLE_BLIST_NODE_IS_BUDDY(child)) |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
816 | continue; |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
817 | |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
818 | buddy = (PurpleBuddy *)child; |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
819 | |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
820 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
821 | purple_buddy_get_name(buddy), |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
822 | purple_buddy_get_account(buddy)); |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
823 | if (conv) |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
824 | purple_conversation_update(conv, PURPLE_CONV_UPDATE_ICON); |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
825 | |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
826 | purple_blist_update_buddy_icon(buddy); |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
827 | } |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
828 | |
|
16533
91e3e84b05f2
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@pidgin.im>
parents:
16532
diff
changeset
|
829 | if (old_img) |
|
91e3e84b05f2
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@pidgin.im>
parents:
16532
diff
changeset
|
830 | purple_imgstore_unref(old_img); |
|
91e3e84b05f2
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@pidgin.im>
parents:
16532
diff
changeset
|
831 | else |
|
91e3e84b05f2
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@pidgin.im>
parents:
16532
diff
changeset
|
832 | { |
|
91e3e84b05f2
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@pidgin.im>
parents:
16532
diff
changeset
|
833 | /* The old icon may not have been loaded into memory. In that |
|
91e3e84b05f2
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@pidgin.im>
parents:
16532
diff
changeset
|
834 | * case, we'll need to uncache the filename. The filenames |
|
91e3e84b05f2
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@pidgin.im>
parents:
16532
diff
changeset
|
835 | * are ref-counted, so this is safe. */ |
|
91e3e84b05f2
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@pidgin.im>
parents:
16532
diff
changeset
|
836 | purple_buddy_icon_data_uncache_file(old_icon); |
|
91e3e84b05f2
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@pidgin.im>
parents:
16532
diff
changeset
|
837 | } |
|
91e3e84b05f2
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@pidgin.im>
parents:
16532
diff
changeset
|
838 | g_free(old_icon); |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
839 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
840 | return img; |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
841 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
842 | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
843 | void |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
844 | purple_buddy_icon_set_old_icons_dir(const char *dirname) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
845 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
846 | old_icons_dir = g_strdup(dirname); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
847 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
848 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
849 | static void |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
850 | migrate_buddy_icon(PurpleBlistNode *node, const char *setting_name, |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
851 | const char *dirname, const char *filename) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
852 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
853 | char *path; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
854 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
855 | if (filename[0] != '/') |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
856 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
857 | path = g_build_filename(dirname, filename, NULL); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
858 | if (g_file_test(path, G_FILE_TEST_EXISTS)) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
859 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
860 | g_free(path); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
861 | return; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
862 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
863 | g_free(path); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
864 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
865 | path = g_build_filename(old_icons_dir, filename, NULL); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
866 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
867 | else |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
868 | path = g_strdup(filename); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
869 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
870 | if (g_file_test(path, G_FILE_TEST_EXISTS)) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
871 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
872 | guchar *icon_data; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
873 | size_t icon_len; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
874 | FILE *file; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
875 | char *new_filename; |
|
9747
5c89f93ad4dc
[gaim-migrate @ 10613]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9396
diff
changeset
|
876 | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
877 | if (!read_icon_file(path, &icon_data, &icon_len)) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
878 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
879 | g_free(path); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
880 | return; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
881 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
882 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
883 | g_free(path); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
884 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
885 | new_filename = purple_buddy_icon_data_calculate_filename(icon_data, icon_len); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
886 | if (new_filename == NULL) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
887 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
888 | return; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
889 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
890 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
891 | path = g_build_filename(dirname, new_filename, NULL); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
892 | if ((file = g_fopen(path, "wb")) != NULL) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
893 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
894 | if (!fwrite(icon_data, icon_len, 1, file)) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
895 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
896 | purple_debug_error("buddyicon", "Error writing %s: %s\n", |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
897 | path, strerror(errno)); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
898 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
899 | else |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
900 | purple_debug_info("buddyicon", "Wrote migrated cache file: %s\n", path); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
901 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
902 | fclose(file); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
903 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
904 | else |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
905 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
906 | purple_debug_error("buddyicon", "Unable to create file %s: %s\n", |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
907 | path, strerror(errno)); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
908 | g_free(new_filename); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
909 | g_free(path); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
910 | return; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
911 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
912 | g_free(path); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
913 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
914 | purple_blist_node_set_string(node, |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
915 | setting_name, |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
916 | new_filename); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
917 | ref_filename(new_filename); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
918 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
919 | g_free(new_filename); |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
920 | |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
921 | if (!strcmp(setting_name, "buddy_icon")) |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
922 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
923 | const char *hash; |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
924 | |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
925 | hash = purple_blist_node_get_string(node, "avatar_hash"); |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
926 | if (hash != NULL) |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
927 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
928 | purple_blist_node_set_string(node, "icon_checksum", hash); |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
929 | purple_blist_node_remove_setting(node, "avatar_hash"); |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
930 | } |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
931 | else |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
932 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
933 | int checksum = purple_blist_node_get_int(node, "icon_checksum"); |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
934 | if (checksum != 0) |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
935 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
936 | char *checksum_str = g_strdup_printf("%i", checksum); |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
937 | purple_blist_node_remove_setting(node, "icon_checksum"); |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
938 | purple_blist_node_set_string(node, "icon_checksum", checksum_str); |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
939 | g_free(checksum_str); |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
940 | } |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
941 | } |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
942 | } |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
943 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
944 | else |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
945 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
946 | /* If the icon is gone, drop the setting... */ |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
947 | purple_blist_node_remove_setting(node, |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
948 | setting_name); |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
949 | |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
950 | if (!strcmp(setting_name, "buddy_icon")) |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
951 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
952 | purple_blist_node_remove_setting(node, |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
953 | "avatar_hash"); |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
954 | purple_blist_node_remove_setting(node, |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
955 | "icon_checksum"); |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
956 | } |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
957 | g_free(path); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
958 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
959 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
960 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
961 | void |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
962 | purple_buddy_icons_blist_loaded_cb() |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
963 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
964 | PurpleBlistNode *node = purple_blist_get_root(); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
965 | const char *dirname = purple_buddy_icons_get_cache_dir(); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
966 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
967 | // TODO: TEMP |
|
16439
c50ef85a3b27
Since I'm about to push this, I'm going to comment out the temp code that references my home directory.
Richard Laager <rlaager@pidgin.im>
parents:
16438
diff
changeset
|
968 | //old_icons_dir = g_strdup("/home/rlaager/.gaim/icons"); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
969 | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
970 | /* Doing this once here saves having to check it inside a loop. */ |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
971 | if (old_icons_dir != NULL) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
972 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
973 | if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
974 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
975 | purple_debug_info("buddyicon", "Creating icon cache directory.\n"); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
976 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
977 | if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
978 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
979 | purple_debug_error("buddyicon", |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
980 | "Unable to create directory %s: %s\n", |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
981 | dirname, strerror(errno)); |
| 9396 | 982 | } |
| 983 | } | |
| 984 | } | |
| 985 | ||
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
986 | while (node != NULL) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
987 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
988 | if (PURPLE_BLIST_NODE_IS_BUDDY(node)) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
989 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
990 | const char *filename; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
991 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
992 | filename = purple_blist_node_get_string(node, "buddy_icon"); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
993 | if (filename != NULL) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
994 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
995 | if (old_icons_dir != NULL) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
996 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
997 | migrate_buddy_icon(node, |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
998 | "buddy_icon", |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
999 | dirname, filename); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1000 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1001 | else |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1002 | { |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
1003 | char *path = g_build_filename(dirname, filename, NULL); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1004 | if (!g_file_test(filename, G_FILE_TEST_EXISTS)) |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1005 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1006 | purple_blist_node_remove_setting(node, |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1007 | "buddy_icon"); |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
1008 | purple_blist_node_remove_setting(node, |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
1009 | "icon_checksum"); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1010 | } |
|
16531
98363f6cdc6c
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@pidgin.im>
parents:
16446
diff
changeset
|
1011 | else |
|
98363f6cdc6c
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@pidgin.im>
parents:
16446
diff
changeset
|
1012 | ref_filename(filename); |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
1013 | g_free(path); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1014 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1015 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1016 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1017 | else if (PURPLE_BLIST_NODE_IS_CONTACT(node)) |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1018 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1019 | const char *filename; |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1020 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1021 | filename = purple_blist_node_get_string(node, "custom_buddy_icon"); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1022 | if (filename != NULL) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1023 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1024 | if (old_icons_dir != NULL) |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1025 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1026 | migrate_buddy_icon(node, |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1027 | "custom_buddy_icon", |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1028 | dirname, filename); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1029 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1030 | else |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1031 | { |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
1032 | char *path = g_build_filename(dirname, filename, NULL); |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
1033 | if (!g_file_test(path, G_FILE_TEST_EXISTS)) |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1034 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1035 | purple_blist_node_remove_setting(node, |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1036 | "custom_buddy_icon"); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1037 | } |
|
16531
98363f6cdc6c
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@pidgin.im>
parents:
16446
diff
changeset
|
1038 | else |
|
98363f6cdc6c
Fix the memory leaking and improper calls to ref_filename(). Also, remove some debugging code.
Richard Laager <rlaager@pidgin.im>
parents:
16446
diff
changeset
|
1039 | ref_filename(filename); |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
1040 | g_free(path); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1041 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1042 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1043 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1044 | node = purple_blist_node_next(node, TRUE); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1045 | } |
| 6846 | 1046 | } |
| 1047 | ||
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1048 | void |
| 15884 | 1049 | purple_buddy_icons_set_caching(gboolean caching) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1050 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1051 | icon_caching = caching; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1052 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1053 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1054 | gboolean |
| 15884 | 1055 | purple_buddy_icons_is_caching(void) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1056 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1057 | return icon_caching; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1058 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1059 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1060 | void |
| 15884 | 1061 | purple_buddy_icons_set_cache_dir(const char *dir) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1062 | { |
|
10811
6b7ac5a9dd35
[gaim-migrate @ 12464]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
1063 | g_return_if_fail(dir != NULL); |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1064 | |
|
13934
c554909e9ff6
[gaim-migrate @ 16342]
Mark Doliner <markdoliner@pidgin.im>
parents:
13555
diff
changeset
|
1065 | g_free(cache_dir); |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1066 | cache_dir = g_strdup(dir); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1067 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1068 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1069 | const char * |
| 15884 | 1070 | purple_buddy_icons_get_cache_dir(void) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1071 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1072 | return cache_dir; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1073 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1074 | |
| 6846 | 1075 | void * |
| 15884 | 1076 | purple_buddy_icons_get_handle() |
| 6846 | 1077 | { |
| 1078 | static int handle; | |
| 1079 | ||
| 1080 | return &handle; | |
| 1081 | } | |
| 1082 | ||
| 1083 | void | |
| 15884 | 1084 | purple_buddy_icons_init() |
| 6846 | 1085 | { |
| 1086 | account_cache = g_hash_table_new_full( | |
| 1087 | g_direct_hash, g_direct_equal, | |
| 1088 | NULL, (GFreeFunc)g_hash_table_destroy); | |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1089 | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1090 | icon_data_cache = g_hash_table_new(g_str_hash, g_str_equal); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1091 | icon_file_cache = g_hash_table_new_full(g_str_hash, g_str_equal, |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1092 | g_free, NULL); |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
1093 | pointer_icon_cache = g_hash_table_new(g_direct_hash, g_direct_equal); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1094 | |
| 15884 | 1095 | cache_dir = g_build_filename(purple_user_dir(), "icons", NULL); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1096 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1097 | purple_signal_connect(purple_imgstore_get_handle(), "image-deleting", |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1098 | purple_buddy_icons_get_handle(), |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1099 | G_CALLBACK(image_deleting_cb), NULL); |
| 6846 | 1100 | } |
| 1101 | ||
| 1102 | void | |
| 15884 | 1103 | purple_buddy_icons_uninit() |
| 6846 | 1104 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1105 | purple_signals_disconnect_by_handle(purple_buddy_icons_get_handle()); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1106 | |
| 6846 | 1107 | g_hash_table_destroy(account_cache); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1108 | g_hash_table_destroy(icon_data_cache); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1109 | g_hash_table_destroy(icon_file_cache); |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
1110 | g_hash_table_destroy(pointer_icon_cache); |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1111 | g_free(old_icons_dir); |
| 6846 | 1112 | } |
| 10483 | 1113 | |
| 15884 | 1114 | void purple_buddy_icon_get_scale_size(PurpleBuddyIconSpec *spec, int *width, int *height) |
| 10483 | 1115 | { |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1116 | int new_width, new_height; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1117 | |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1118 | new_width = *width; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1119 | new_height = *height; |
|
10523
ef52a88a8512
[gaim-migrate @ 11840]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10483
diff
changeset
|
1120 | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1121 | if (*width < spec->min_width) |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1122 | new_width = spec->min_width; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1123 | else if (*width > spec->max_width) |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1124 | new_width = spec->max_width; |
| 10483 | 1125 | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1126 | if (*height < spec->min_height) |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1127 | new_height = spec->min_height; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1128 | else if (*height > spec->max_height) |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1129 | new_height = spec->max_height; |
|
10523
ef52a88a8512
[gaim-migrate @ 11840]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10483
diff
changeset
|
1130 | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1131 | /* preserve aspect ratio */ |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1132 | if ((double)*height * (double)new_width > |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1133 | (double)*width * (double)new_height) { |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1134 | new_width = 0.5 + (double)*width * (double)new_height / (double)*height; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1135 | } else { |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1136 | new_height = 0.5 + (double)*height * (double)new_width / (double)*width; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1137 | } |
|
10523
ef52a88a8512
[gaim-migrate @ 11840]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10483
diff
changeset
|
1138 | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1139 | *width = new_width; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1140 | *height = new_height; |
| 10483 | 1141 | } |