Thu, 28 Sep 2017 20:33:59 -0500
closing merged branch
| 6846 | 1 | /** |
|
22763
6e4bbebdf127
Better documentation.
Mark Doliner <markdoliner@pidgin.im>
parents:
22551
diff
changeset
|
2 | * @file buddyicon.c Buddy Icon API |
| 6846 | 3 | * @ingroup core |
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
4 | */ |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
5 | |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
6 | /* purple |
| 6846 | 7 | * |
| 15884 | 8 | * Purple is the legal property of its developers, whose names are too numerous |
| 8046 | 9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 10 | * source distribution. | |
| 6846 | 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify | |
| 13 | * it under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation; either version 2 of the License, or | |
| 15 | * (at your option) any later version. | |
| 16 | * | |
| 17 | * This program is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 23 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18122
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 6846 | 25 | */ |
|
24569
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
24273
diff
changeset
|
26 | #define _PURPLE_BUDDYICON_C_ |
|
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
24273
diff
changeset
|
27 | |
| 6846 | 28 | #include "internal.h" |
| 29 | #include "buddyicon.h" | |
| 30 | #include "conversation.h" | |
|
13555
b4d6a5e6853a
[gaim-migrate @ 15932]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12996
diff
changeset
|
31 | #include "dbus-maybe.h" |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
32 | #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
|
33 | #include "imgstore.h" |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
34 | #include "util.h" |
| 6846 | 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. */ |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
41 | PurpleStoredImage *img; /**< The stored image containing |
|
16437
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 | |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
48 | /** |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
49 | * This is the big grand daddy hash table that contains references to |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
50 | * everybody's buddy icons. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
51 | * |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
52 | * Key is a PurpleAccount. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
53 | * Value is another hash table, usually referred to as "icon_cache." |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
54 | * For this inner hash table: |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
55 | * Key is the username of the buddy whose icon is being stored. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
56 | * Value is the PurpleBuddyIcon for this buddy. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
57 | */ |
| 6846 | 58 | static GHashTable *account_cache = NULL; |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
59 | |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
60 | /** |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
61 | * This hash table contains a bunch of PurpleStoredImages that are |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
62 | * shared across all accounts. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
63 | * |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
64 | * Key is the filename for this image as constructed by |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
65 | * purple_util_get_image_filename(). So it is the base16 encoded |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
66 | * sha-1 hash plus an appropriate file extension. For example: |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
67 | * "0f4972d17d1e70e751c43c90c948e72efbff9796.gif" |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
68 | * |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
69 | * The value is a PurpleStoredImage containing the icon data. These |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
70 | * images are reference counted, and when the count reaches 0 |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
71 | * imgstore.c emits the image-deleting signal and we remove the image |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
72 | * from the hash table (but it might still be saved on disk, if the |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
73 | * icon is being used by offline accounts or some such). |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
74 | */ |
|
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
|
75 | static GHashTable *icon_data_cache = NULL; |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
76 | |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
77 | /** |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
78 | * This hash table contains references counts for how many times each |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
79 | * icon in the ~/.purple/icons/ directory is being used. It's pretty |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
80 | * crazy. It maintains the reference count across sessions, too, so |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
81 | * if you exit Pidgin then this hash table is reconstructed the next |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
82 | * time Pidgin starts. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
83 | * |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
84 | * Key is the filename for this image as constructed by |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
85 | * purple_util_get_image_filename(). So it is the base16 encoded |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
86 | * sha-1 hash plus an appropriate file extension. For example: |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
87 | * "0f4972d17d1e70e751c43c90c948e72efbff9796.gif" |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
88 | * |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
89 | * The value is a GINT_TO_POINTER count of the number of times this |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
90 | * icon is used. So if four of your buddies are using an icon, and |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
91 | * you have the icon set for two of your accounts, then this number |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
92 | * will be six. When this reference count reaches 0 the icon will |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
93 | * be deleted from disk. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
94 | */ |
|
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
|
95 | 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
|
96 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
97 | /** |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
98 | * This hash table is used for both custom buddy icons on PurpleBlistNodes and |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
99 | * account icons. |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
100 | */ |
|
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
|
101 | 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
|
102 | |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
103 | static char *cache_dir = NULL; |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
104 | |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
105 | /** "Should icons be cached to disk?" */ |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
106 | static gboolean icon_caching = TRUE; |
| 6846 | 107 | |
|
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
|
108 | /* 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
|
109 | 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
|
110 | |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
111 | static void delete_buddy_icon_settings(PurpleBlistNode *node, const char *setting_name); |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
112 | |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
113 | /* |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
114 | * Begin functions for dealing with the on-disk icon cache |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
115 | */ |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
116 | |
|
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
|
117 | 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
|
118 | 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
|
119 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
120 | 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
|
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 | 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
|
123 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
124 | 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
|
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 | 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
|
127 | 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
|
128 | } |
|
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 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
130 | 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
|
131 | 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
|
132 | { |
|
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 | 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
|
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 | 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
|
136 | 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
|
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 | 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
|
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 | 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
|
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 | 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
|
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 | 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
|
145 | { |
|
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 | 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
|
147 | 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
|
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 | |
|
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 | 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
|
152 | 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
|
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 | 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
|
155 | char *path; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
156 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
157 | 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
|
158 | |
|
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
|
159 | 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
|
160 | 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
|
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 | 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
|
163 | 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
|
164 | |
|
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 | 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
|
166 | { |
|
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 | 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
|
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 | 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
|
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 | 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
|
172 | "Unable to create directory %s: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20242
diff
changeset
|
173 | dirname, g_strerror(errno)); |
|
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 | } |
|
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 | |
|
22551
a860a56287cd
Just write out the buddy icon file; there's no need to check to see if it exists. This is for the cache, and if the blist.xml gets out of sync with the cache on disk (for example, because the user moves the blist.xml file out of the way), the existing code will never update the cached icon again.
Evan Schoenberg <evands@pidgin.im>
parents:
22547
diff
changeset
|
177 | purple_util_write_data_to_file_absolute(path, purple_imgstore_get_data(img), |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
178 | purple_imgstore_get_size(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
|
179 | 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
|
180 | } |
|
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 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
182 | 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
|
183 | 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
|
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 | 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
|
186 | 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
|
187 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
188 | 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
|
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 | /* 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
|
191 | * 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
|
192 | 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
|
193 | 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
|
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 | 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
|
196 | 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
|
197 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
198 | 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
|
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 | 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
|
201 | { |
|
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 | purple_debug_error("buddyicon", "Failed to delete %s: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20242
diff
changeset
|
203 | path, g_strerror(errno)); |
|
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
|
204 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
205 | 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
|
206 | { |
|
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
|
207 | 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
|
208 | } |
|
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
|
209 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
210 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
211 | 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
|
212 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
213 | |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
214 | /* |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
215 | * End functions for dealing with the on-disk icon cache |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
216 | */ |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
217 | |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
218 | /* |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
219 | * Begin functions for dealing with the in-memory icon cache |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
220 | */ |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
221 | |
|
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
|
222 | 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
|
223 | 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
|
224 | { |
|
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
|
225 | 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
|
226 | } |
|
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
|
227 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
228 | static void |
|
16740
c95b1a276ea1
Document the image-deleting signal.
Richard Laager <rlaager@pidgin.im>
parents:
16727
diff
changeset
|
229 | image_deleting_cb(const 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
|
230 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
231 | 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
|
232 | |
|
16679
59e879c13ee8
Fix a crash when removing a per-account icon. Here's my explanation:
Richard Laager <rlaager@pidgin.im>
parents:
16678
diff
changeset
|
233 | /* If there's no filename, it can't be one of our images. */ |
|
59e879c13ee8
Fix a crash when removing a per-account icon. Here's my explanation:
Richard Laager <rlaager@pidgin.im>
parents:
16678
diff
changeset
|
234 | if (filename == NULL) |
|
59e879c13ee8
Fix a crash when removing a per-account icon. Here's my explanation:
Richard Laager <rlaager@pidgin.im>
parents:
16678
diff
changeset
|
235 | return; |
|
59e879c13ee8
Fix a crash when removing a per-account icon. Here's my explanation:
Richard Laager <rlaager@pidgin.im>
parents:
16678
diff
changeset
|
236 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
237 | 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
|
238 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
239 | 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
|
240 | 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
|
241 | |
|
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
|
242 | /* 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
|
243 | * this is probably good enough. */ |
|
16775
8627d2560d40
Get rid of two harmless warnings:
Mark Doliner <markdoliner@pidgin.im>
parents:
16740
diff
changeset
|
244 | g_hash_table_foreach_remove(pointer_icon_cache, value_equals, (gpointer)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
|
245 | } |
|
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 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
247 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
248 | 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
|
249 | 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
|
250 | { |
|
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 | 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
|
252 | 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
|
253 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
254 | 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
|
255 | 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
|
256 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
257 | 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
|
258 | { |
|
18101
3ce21b5a182c
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@pidgin.im>
parents:
17033
diff
changeset
|
259 | file = purple_util_get_image_filename(icon_data, icon_len); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
260 | 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
|
261 | { |
|
75a20ae3a527
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@pidgin.im>
parents:
16538
diff
changeset
|
262 | 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
|
263 | 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
|
264 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
265 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
266 | else |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
267 | 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
|
268 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
269 | 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
|
270 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
271 | 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
|
272 | 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
|
273 | 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
|
274 | } |
|
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 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
276 | 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
|
277 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
278 | /* 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
|
279 | 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
|
280 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
281 | 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
|
282 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
283 | 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
|
284 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
285 | |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
286 | /* |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
287 | * End functions for dealing with the in-memory icon cache |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
288 | */ |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
289 | |
| 15884 | 290 | static PurpleBuddyIcon * |
| 291 | purple_buddy_icon_create(PurpleAccount *account, const char *username) | |
| 9396 | 292 | { |
| 15884 | 293 | PurpleBuddyIcon *icon; |
| 9396 | 294 | GHashTable *icon_cache; |
| 295 | ||
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
296 | /* 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
|
297 | * 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
|
298 | icon = g_slice_new(PurpleBuddyIcon); |
| 15884 | 299 | PURPLE_DBUS_REGISTER_POINTER(icon, PurpleBuddyIcon); |
| 9396 | 300 | |
|
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
|
301 | 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
|
302 | 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
|
303 | icon->checksum = NULL; |
|
16924
a061b2ff4cf7
Fix a reference counting bug.
Richard Laager <rlaager@pidgin.im>
parents:
16903
diff
changeset
|
304 | icon->ref_count = 1; |
| 9396 | 305 | |
| 306 | icon_cache = g_hash_table_lookup(account_cache, account); | |
| 307 | ||
| 308 | if (icon_cache == NULL) | |
| 309 | { | |
| 310 | icon_cache = g_hash_table_new(g_str_hash, g_str_equal); | |
| 311 | ||
| 312 | g_hash_table_insert(account_cache, account, icon_cache); | |
| 313 | } | |
| 314 | ||
| 315 | 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
|
316 | (char *)purple_buddy_icon_get_username(icon), icon); |
| 9396 | 317 | return icon; |
| 318 | } | |
| 319 | ||
| 15884 | 320 | PurpleBuddyIcon * |
| 321 | 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
|
322 | 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
|
323 | const char *checksum) |
| 6846 | 324 | { |
| 15884 | 325 | PurpleBuddyIcon *icon; |
| 6846 | 326 | |
| 327 | g_return_val_if_fail(account != NULL, NULL); | |
| 328 | 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
|
329 | 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
|
330 | g_return_val_if_fail(icon_len > 0, NULL); |
| 6846 | 331 | |
|
16438
64e892ac6180
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
332 | /* 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
|
333 | * sure to update it as well when members are added. */ |
| 15884 | 334 | icon = purple_buddy_icons_find(account, username); |
| 6846 | 335 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
336 | /* purple_buddy_icon_create() sets account & username */ |
| 6846 | 337 | if (icon == NULL) |
| 15884 | 338 | icon = purple_buddy_icon_create(account, username); |
| 6846 | 339 | |
|
16438
64e892ac6180
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
340 | /* 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
|
341 | * 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
|
342 | 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
|
343 | 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
|
344 | |
| 6846 | 345 | return icon; |
| 346 | } | |
| 347 | ||
| 15884 | 348 | PurpleBuddyIcon * |
| 349 | purple_buddy_icon_ref(PurpleBuddyIcon *icon) | |
| 6846 | 350 | { |
| 351 | g_return_val_if_fail(icon != NULL, NULL); | |
| 352 | ||
| 353 | icon->ref_count++; | |
| 354 | ||
| 355 | return icon; | |
| 356 | } | |
| 357 | ||
| 15884 | 358 | PurpleBuddyIcon * |
| 359 | purple_buddy_icon_unref(PurpleBuddyIcon *icon) | |
| 6846 | 360 | { |
|
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
|
361 | 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
|
362 | 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
|
363 | |
|
12250
5b14301dd1ec
[gaim-migrate @ 14552]
Richard Laager <rlaager@pidgin.im>
parents:
12097
diff
changeset
|
364 | g_return_val_if_fail(icon->ref_count > 0, NULL); |
| 6846 | 365 | |
| 366 | icon->ref_count--; | |
| 367 | ||
| 368 | if (icon->ref_count == 0) | |
| 369 | { | |
|
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 | 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
|
371 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
372 | 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
|
373 | 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
|
374 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
375 | 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
|
376 | 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
|
377 | 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
|
378 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
379 | 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
|
380 | g_slice_free(PurpleBuddyIcon, icon); |
| 6846 | 381 | |
| 382 | return NULL; | |
| 383 | } | |
| 384 | ||
| 385 | return icon; | |
| 386 | } | |
| 387 | ||
| 388 | void | |
| 15884 | 389 | purple_buddy_icon_update(PurpleBuddyIcon *icon) |
| 6846 | 390 | { |
| 15884 | 391 | PurpleConversation *conv; |
| 392 | PurpleAccount *account; | |
| 6846 | 393 | 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
|
394 | PurpleBuddyIcon *icon_to_set; |
|
16863
b98303c15033
Change a few functions to free a linked list while iterating through
Mark Doliner <markdoliner@pidgin.im>
parents:
16775
diff
changeset
|
395 | GSList *buddies; |
| 6846 | 396 | |
| 397 | g_return_if_fail(icon != NULL); | |
| 398 | ||
| 15884 | 399 | account = purple_buddy_icon_get_account(icon); |
| 400 | username = purple_buddy_icon_get_username(icon); | |
| 6846 | 401 | |
|
16875
e1c6d9541cb9
Protect icon with ref/unref guards since it may be freed over the course of the while() loop. I thought this would fix #398, but something else is wrong, too.
Evan Schoenberg <evands@pidgin.im>
parents:
16874
diff
changeset
|
402 | /* If no data exists (icon->img == NULL), then call the functions below |
|
e1c6d9541cb9
Protect icon with ref/unref guards since it may be freed over the course of the while() loop. I thought this would fix #398, but something else is wrong, too.
Evan Schoenberg <evands@pidgin.im>
parents:
16874
diff
changeset
|
403 | * with NULL to unset the icon. They will then unref the icon and it should |
|
e1c6d9541cb9
Protect icon with ref/unref guards since it may be freed over the course of the while() loop. I thought this would fix #398, but something else is wrong, too.
Evan Schoenberg <evands@pidgin.im>
parents:
16874
diff
changeset
|
404 | * be destroyed. The only way it wouldn't be destroyed is if someone |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
405 | * 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
|
406 | * 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
|
407 | 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
|
408 | |
|
16875
e1c6d9541cb9
Protect icon with ref/unref guards since it may be freed over the course of the while() loop. I thought this would fix #398, but something else is wrong, too.
Evan Schoenberg <evands@pidgin.im>
parents:
16874
diff
changeset
|
409 | /* Ensure that icon remains valid throughout */ |
|
33769
96f89e35d24d
Fix various "Dereference before null check" issues
Daniel Atallah <datallah@pidgin.im>
parents:
29296
diff
changeset
|
410 | purple_buddy_icon_ref(icon); |
|
16875
e1c6d9541cb9
Protect icon with ref/unref guards since it may be freed over the course of the while() loop. I thought this would fix #398, but something else is wrong, too.
Evan Schoenberg <evands@pidgin.im>
parents:
16874
diff
changeset
|
411 | |
|
16863
b98303c15033
Change a few functions to free a linked list while iterating through
Mark Doliner <markdoliner@pidgin.im>
parents:
16775
diff
changeset
|
412 | buddies = purple_find_buddies(account, username); |
|
b98303c15033
Change a few functions to free a linked list while iterating through
Mark Doliner <markdoliner@pidgin.im>
parents:
16775
diff
changeset
|
413 | while (buddies != NULL) |
| 6846 | 414 | { |
|
16863
b98303c15033
Change a few functions to free a linked list while iterating through
Mark Doliner <markdoliner@pidgin.im>
parents:
16775
diff
changeset
|
415 | PurpleBuddy *buddy = (PurpleBuddy *)buddies->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
|
416 | char *old_icon; |
| 6846 | 417 | |
|
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
|
418 | purple_buddy_set_icon(buddy, icon_to_set); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
419 | 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
|
420 | "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
|
421 | 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
|
422 | { |
|
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 | 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
|
424 | 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
|
425 | "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
|
426 | 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
|
427 | |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
428 | 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
|
429 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
430 | 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
|
431 | "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
|
432 | 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
|
433 | } |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
434 | 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
|
435 | { |
|
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 | 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
|
437 | "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
|
438 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
439 | 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
|
440 | } |
|
17033
27d9faa34ad1
Patch from ticket #819 from vampire
Richard Laager <rlaager@pidgin.im>
parents:
16924
diff
changeset
|
441 | else 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
|
442 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
443 | 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
|
444 | 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
|
445 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
446 | 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
|
447 | g_free(old_icon); |
|
16863
b98303c15033
Change a few functions to free a linked list while iterating through
Mark Doliner <markdoliner@pidgin.im>
parents:
16775
diff
changeset
|
448 | |
|
b98303c15033
Change a few functions to free a linked list while iterating through
Mark Doliner <markdoliner@pidgin.im>
parents:
16775
diff
changeset
|
449 | buddies = g_slist_delete_link(buddies, buddies); |
| 6846 | 450 | } |
| 451 | ||
| 15884 | 452 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, username, account); |
| 6846 | 453 | |
|
10246
aa5bff72f94c
[gaim-migrate @ 11386]
Mark Doliner <markdoliner@pidgin.im>
parents:
9801
diff
changeset
|
454 | 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
|
455 | purple_conv_im_set_icon(PURPLE_CONV_IM(conv), icon_to_set); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
456 | |
|
16875
e1c6d9541cb9
Protect icon with ref/unref guards since it may be freed over the course of the while() loop. I thought this would fix #398, but something else is wrong, too.
Evan Schoenberg <evands@pidgin.im>
parents:
16874
diff
changeset
|
457 | /* icon's refcount was incremented above */ |
|
33788
83e5594ced88
Fix a few bogus NULL checks
Daniel Atallah <datallah@pidgin.im>
parents:
33769
diff
changeset
|
458 | purple_buddy_icon_unref(icon); |
|
11040
37e247d18e78
[gaim-migrate @ 12940]
Richard Laager <rlaager@pidgin.im>
parents:
11033
diff
changeset
|
459 | } |
|
37e247d18e78
[gaim-migrate @ 12940]
Richard Laager <rlaager@pidgin.im>
parents:
11033
diff
changeset
|
460 | |
| 6846 | 461 | 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
|
462 | 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
|
463 | size_t len, const char *checksum) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
464 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
465 | PurpleStoredImage *old_img; |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
466 | |
|
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
|
467 | g_return_if_fail(icon != NULL); |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
468 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
469 | 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
|
470 | icon->img = NULL; |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
471 | |
|
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
|
472 | if (data != NULL) |
|
16544
945caa0d6436
Kill some compiler warnings and TODOs of mine.
Richard Laager <rlaager@pidgin.im>
parents:
16539
diff
changeset
|
473 | { |
|
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
|
474 | 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
|
475 | 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
|
476 | 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
|
477 | g_free(data); |
|
16544
945caa0d6436
Kill some compiler warnings and TODOs of mine.
Richard Laager <rlaager@pidgin.im>
parents:
16539
diff
changeset
|
478 | } |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
479 | |
|
16874
cd539323cabe
Remove two warnings, one compile-time, one runtime. Plug two leaks, both runtime.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16863
diff
changeset
|
480 | g_free(icon->checksum); |
|
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
|
481 | 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
|
482 | |
|
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
|
483 | purple_buddy_icon_update(icon); |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
484 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
485 | purple_imgstore_unref(old_img); |
|
15132
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
486 | } |
|
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
487 | |
| 15884 | 488 | PurpleAccount * |
| 489 | purple_buddy_icon_get_account(const PurpleBuddyIcon *icon) | |
| 6846 | 490 | { |
| 491 | g_return_val_if_fail(icon != NULL, NULL); | |
| 492 | ||
| 493 | return icon->account; | |
| 494 | } | |
| 495 | ||
| 496 | const char * | |
| 15884 | 497 | purple_buddy_icon_get_username(const PurpleBuddyIcon *icon) |
| 6846 | 498 | { |
| 499 | g_return_val_if_fail(icon != NULL, NULL); | |
| 500 | ||
| 501 | return icon->username; | |
| 502 | } | |
| 503 | ||
|
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
|
504 | 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
|
505 | 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
|
506 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
507 | 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
|
508 | |
|
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 | 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
|
510 | } |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
511 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
512 | gconstpointer |
| 15884 | 513 | purple_buddy_icon_get_data(const PurpleBuddyIcon *icon, size_t *len) |
| 6846 | 514 | { |
| 515 | g_return_val_if_fail(icon != NULL, NULL); | |
| 516 | ||
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
517 | 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
|
518 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
519 | 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
|
520 | *len = purple_imgstore_get_size(icon->img); |
| 6846 | 521 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
522 | 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
|
523 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
524 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
525 | return NULL; |
|
15132
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
526 | } |
|
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
527 | |
|
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
528 | 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
|
529 | purple_buddy_icon_get_extension(const PurpleBuddyIcon *icon) |
|
10953
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
530 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
531 | 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
|
532 | return purple_imgstore_get_extension(icon->img); |
|
10953
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
533 | |
|
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
534 | return NULL; |
|
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
535 | } |
|
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
536 | |
| 6846 | 537 | void |
| 15884 | 538 | 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
|
539 | 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
|
540 | const char *checksum) |
| 6846 | 541 | { |
|
16900
e9f12eb06c5b
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@pidgin.im>
parents:
16863
diff
changeset
|
542 | GHashTable *icon_cache; |
|
e9f12eb06c5b
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@pidgin.im>
parents:
16863
diff
changeset
|
543 | PurpleBuddyIcon *icon = NULL; |
|
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
|
544 | |
| 6846 | 545 | g_return_if_fail(account != NULL); |
| 546 | g_return_if_fail(username != NULL); | |
| 547 | ||
|
16900
e9f12eb06c5b
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@pidgin.im>
parents:
16863
diff
changeset
|
548 | icon_cache = g_hash_table_lookup(account_cache, account); |
|
e9f12eb06c5b
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@pidgin.im>
parents:
16863
diff
changeset
|
549 | |
|
e9f12eb06c5b
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@pidgin.im>
parents:
16863
diff
changeset
|
550 | if (icon_cache != NULL) |
|
e9f12eb06c5b
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@pidgin.im>
parents:
16863
diff
changeset
|
551 | icon = g_hash_table_lookup(icon_cache, username); |
|
9305
63a1b462a208
[gaim-migrate @ 10113]
Christian Hammond <chipx86@chipx86.com>
parents:
9285
diff
changeset
|
552 | |
|
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
|
553 | 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
|
554 | purple_buddy_icon_set_data(icon, icon_data, icon_len, checksum); |
|
16874
cd539323cabe
Remove two warnings, one compile-time, one runtime. Plug two leaks, both runtime.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16863
diff
changeset
|
555 | else if (icon_data && icon_len > 0) |
|
9305
63a1b462a208
[gaim-migrate @ 10113]
Christian Hammond <chipx86@chipx86.com>
parents:
9285
diff
changeset
|
556 | { |
|
20242
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
557 | PurpleBuddyIcon *icon = purple_buddy_icon_new(account, username, icon_data, icon_len, checksum); |
|
16900
e9f12eb06c5b
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@pidgin.im>
parents:
16863
diff
changeset
|
558 | |
|
20242
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
559 | /* purple_buddy_icon_new() calls |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
560 | * purple_buddy_icon_set_data(), which calls |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
561 | * purple_buddy_icon_update(), which has the buddy list |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
562 | * and conversations take references as appropriate. |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
563 | * This function doesn't return icon, so we can't |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
564 | * leave a reference dangling. */ |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
565 | purple_buddy_icon_unref(icon); |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
566 | } |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
567 | else |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
568 | { |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
569 | /* If the buddy list or a conversation was holding a |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
570 | * reference, we'd have found the icon in the cache. |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
571 | * Since we know we're deleting the icon, we only |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
572 | * need a subset of purple_buddy_icon_update(). */ |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
573 | |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
574 | GSList *buddies = purple_find_buddies(account, username); |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
575 | while (buddies != NULL) |
|
16900
e9f12eb06c5b
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@pidgin.im>
parents:
16863
diff
changeset
|
576 | { |
|
20242
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
577 | PurpleBuddy *buddy = (PurpleBuddy *)buddies->data; |
|
16900
e9f12eb06c5b
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@pidgin.im>
parents:
16863
diff
changeset
|
578 | |
|
20242
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
579 | unref_filename(purple_blist_node_get_string((PurpleBlistNode *)buddy, "buddy_icon")); |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
580 | purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "buddy_icon"); |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
581 | purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "icon_checksum"); |
|
16900
e9f12eb06c5b
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@pidgin.im>
parents:
16863
diff
changeset
|
582 | |
|
20242
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
583 | buddies = g_slist_delete_link(buddies, buddies); |
|
16900
e9f12eb06c5b
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@pidgin.im>
parents:
16863
diff
changeset
|
584 | } |
|
9305
63a1b462a208
[gaim-migrate @ 10113]
Christian Hammond <chipx86@chipx86.com>
parents:
9285
diff
changeset
|
585 | } |
| 6846 | 586 | } |
| 587 | ||
|
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
|
588 | 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
|
589 | { |
|
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
|
590 | 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
|
591 | |
|
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
|
592 | 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
|
593 | |
|
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
|
594 | 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
|
595 | 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
|
596 | |
|
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
|
597 | 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
|
598 | 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
|
599 | 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
|
600 | { |
|
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
|
601 | 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
|
602 | 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
|
603 | } |
|
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
|
604 | 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
|
605 | } |
|
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
|
606 | |
|
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
|
607 | 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
|
608 | 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
|
609 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
610 | 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
|
611 | "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
|
612 | } |
|
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 | 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
|
615 | 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
|
616 | { |
|
16532
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
617 | 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
|
618 | |
|
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
|
619 | 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
|
620 | { |
|
16532
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
621 | 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
|
622 | 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
|
623 | 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
|
624 | |
|
16532
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
625 | 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
|
626 | } |
|
16532
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
627 | |
|
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
628 | 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
|
629 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
630 | |
| 15884 | 631 | PurpleBuddyIcon * |
| 632 | purple_buddy_icons_find(PurpleAccount *account, const char *username) | |
| 6846 | 633 | { |
| 634 | 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
|
635 | PurpleBuddyIcon *icon = NULL; |
| 6846 | 636 | |
| 637 | g_return_val_if_fail(account != NULL, NULL); | |
| 638 | g_return_val_if_fail(username != NULL, NULL); | |
| 639 | ||
| 640 | icon_cache = g_hash_table_lookup(account_cache, account); | |
| 641 | ||
|
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
|
642 | 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
|
643 | { |
| 15884 | 644 | 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
|
645 | 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
|
646 | 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
|
647 | 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
|
648 | 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
|
649 | size_t len; |
| 9396 | 650 | |
| 651 | if (!b) | |
| 652 | return NULL; | |
| 653 | ||
|
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
|
654 | 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
|
655 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
656 | if (protocol_icon_file == NULL) |
| 9396 | 657 | return NULL; |
| 6846 | 658 | |
|
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
|
659 | 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
|
660 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
661 | 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
|
662 | /* 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
|
663 | * 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
|
664 | * 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
|
665 | 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
|
666 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
667 | 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
|
668 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
669 | 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
|
670 | 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
|
671 | { |
|
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
|
672 | 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
|
673 | |
|
16874
cd539323cabe
Remove two warnings, one compile-time, one runtime. Plug two leaks, both runtime.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16863
diff
changeset
|
674 | 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
|
675 | icon->img = NULL; |
|
16874
cd539323cabe
Remove two warnings, one compile-time, one runtime. Plug two leaks, both runtime.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16863
diff
changeset
|
676 | checksum = purple_blist_node_get_string((PurpleBlistNode*)b, "icon_checksum"); |
|
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
|
677 | 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
|
678 | } |
|
22148
66b0ed947da5
If the cached buddy icon can't be loaded, delete the preferences which point to it. Among other things, this fixes OSCAR buddy icon retrieval when the cache has been removed - since previously the icon hash was kept around and was used to determine that (so far as the prpl could tell) no icon retrieval was needed, libpurple would never have an icon for the contact.
Evan Schoenberg <evands@pidgin.im>
parents:
22120
diff
changeset
|
679 | else |
|
66b0ed947da5
If the cached buddy icon can't be loaded, delete the preferences which point to it. Among other things, this fixes OSCAR buddy icon retrieval when the cache has been removed - since previously the icon hash was kept around and was used to determine that (so far as the prpl could tell) no icon retrieval was needed, libpurple would never have an icon for the contact.
Evan Schoenberg <evands@pidgin.im>
parents:
22120
diff
changeset
|
680 | delete_buddy_icon_settings((PurpleBlistNode*)b, "buddy_icon"); |
|
22154
b7ab5a12d97a
Remove spurious braces
Evan Schoenberg <evands@pidgin.im>
parents:
22150
diff
changeset
|
681 | |
|
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
|
682 | 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
|
683 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
684 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
685 | 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
|
686 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
687 | |
|
22161
be6ccc274119
Apparently "nil" is an Objective-C thing
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22158
diff
changeset
|
688 | return (icon ? purple_buddy_icon_ref(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
|
689 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
690 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
691 | 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
|
692 | 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
|
693 | { |
|
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 | 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
|
695 | 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
|
696 | 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
|
697 | 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
|
698 | 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
|
699 | 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
|
700 | |
|
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 | 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
|
702 | |
|
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 | 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
|
704 | { |
|
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 | 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
|
706 | } |
|
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 | |
|
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 | 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
|
709 | |
|
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 | 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
|
711 | 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
|
712 | |
|
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 | 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
|
714 | 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
|
715 | |
|
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 | 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
|
717 | { |
|
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 | g_free(path); |
|
29234
1d444b1479d7
Fix a crash when setting a buddyicon.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27783
diff
changeset
|
719 | img = purple_buddy_icons_set_account_icon(account, data, len); |
|
1d444b1479d7
Fix a crash when setting a buddyicon.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27783
diff
changeset
|
720 | return purple_imgstore_ref(img); |
|
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
|
721 | } |
|
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 | 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
|
723 | |
|
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 | 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
|
725 | } |
|
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 | |
|
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 | 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
|
728 | 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
|
729 | 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
|
730 | { |
|
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 | 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
|
732 | 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
|
733 | 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
|
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 | 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
|
736 | { |
|
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
|
737 | 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
|
738 | } |
|
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
|
739 | |
|
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
|
740 | 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
|
741 | 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
|
742 | { |
|
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
|
743 | 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
|
744 | purple_account_set_string(account, "buddy_icon", filename); |
|
16677
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
745 | purple_account_set_int(account, "buddy_icon_timestamp", time(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
|
746 | 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
|
747 | } |
|
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
|
748 | 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
|
749 | { |
|
16544
945caa0d6436
Kill some compiler warnings and TODOs of mine.
Richard Laager <rlaager@pidgin.im>
parents:
16539
diff
changeset
|
750 | purple_account_set_string(account, "buddy_icon", NULL); |
|
16677
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
751 | purple_account_set_int(account, "buddy_icon_timestamp", 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
|
752 | } |
|
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
|
753 | 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
|
754 | |
|
25745
48b7ebd7fcc7
Fix the crash/leaks in statusbox
Paul Aurich <darkrain42@pidgin.im>
parents:
24569
diff
changeset
|
755 | old_img = g_hash_table_lookup(pointer_icon_cache, account); |
|
48b7ebd7fcc7
Fix the crash/leaks in statusbox
Paul Aurich <darkrain42@pidgin.im>
parents:
24569
diff
changeset
|
756 | |
|
22547
342b81d25863
When purple_buddy_icons_set_account_icon() is called, it unrefs the old PurpleStoredImage and refs the new one. Previously, it notified the prpl of the change in the buddy icon before updating pointer_icon_cache, which meant that if the prpl then called purple_buddy_icons_find_account_icon() it would get the old PurpleStoredImage (which is at this point not only old but also a pointer to invalid memory if unref'ing it caused it to be destroyed). This happens in jabber_set_info() as of 2.4.0, causing a crash when setting no-buddy-icon for an account after it has previously had an icon. I think this also means that XMPP accounts in 2.4.0 will also always set serverside the *last* icon set, not the current one, when changing icons, but I didn't test that.
Evan Schoenberg <evands@pidgin.im>
parents:
22390
diff
changeset
|
757 | if (img) |
|
342b81d25863
When purple_buddy_icons_set_account_icon() is called, it unrefs the old PurpleStoredImage and refs the new one. Previously, it notified the prpl of the change in the buddy icon before updating pointer_icon_cache, which meant that if the prpl then called purple_buddy_icons_find_account_icon() it would get the old PurpleStoredImage (which is at this point not only old but also a pointer to invalid memory if unref'ing it caused it to be destroyed). This happens in jabber_set_info() as of 2.4.0, causing a crash when setting no-buddy-icon for an account after it has previously had an icon. I think this also means that XMPP accounts in 2.4.0 will also always set serverside the *last* icon set, not the current one, when changing icons, but I didn't test that.
Evan Schoenberg <evands@pidgin.im>
parents:
22390
diff
changeset
|
758 | g_hash_table_insert(pointer_icon_cache, account, img); |
|
342b81d25863
When purple_buddy_icons_set_account_icon() is called, it unrefs the old PurpleStoredImage and refs the new one. Previously, it notified the prpl of the change in the buddy icon before updating pointer_icon_cache, which meant that if the prpl then called purple_buddy_icons_find_account_icon() it would get the old PurpleStoredImage (which is at this point not only old but also a pointer to invalid memory if unref'ing it caused it to be destroyed). This happens in jabber_set_info() as of 2.4.0, causing a crash when setting no-buddy-icon for an account after it has previously had an icon. I think this also means that XMPP accounts in 2.4.0 will also always set serverside the *last* icon set, not the current one, when changing icons, but I didn't test that.
Evan Schoenberg <evands@pidgin.im>
parents:
22390
diff
changeset
|
759 | else |
|
342b81d25863
When purple_buddy_icons_set_account_icon() is called, it unrefs the old PurpleStoredImage and refs the new one. Previously, it notified the prpl of the change in the buddy icon before updating pointer_icon_cache, which meant that if the prpl then called purple_buddy_icons_find_account_icon() it would get the old PurpleStoredImage (which is at this point not only old but also a pointer to invalid memory if unref'ing it caused it to be destroyed). This happens in jabber_set_info() as of 2.4.0, causing a crash when setting no-buddy-icon for an account after it has previously had an icon. I think this also means that XMPP accounts in 2.4.0 will also always set serverside the *last* icon set, not the current one, when changing icons, but I didn't test that.
Evan Schoenberg <evands@pidgin.im>
parents:
22390
diff
changeset
|
760 | g_hash_table_remove(pointer_icon_cache, account); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
761 | |
|
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
|
762 | 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
|
763 | { |
|
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 | 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
|
765 | 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
|
766 | |
|
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
|
767 | gc = purple_account_get_connection(account); |
|
22390
d22357d5c7ba
Kill off gc->prpl in the core everywhere but connection.c (when the struct
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22307
diff
changeset
|
768 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
|
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
|
769 | |
|
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
|
770 | 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
|
771 | 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
|
772 | } |
|
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
|
773 | |
|
25745
48b7ebd7fcc7
Fix the crash/leaks in statusbox
Paul Aurich <darkrain42@pidgin.im>
parents:
24569
diff
changeset
|
774 | if (old_img) |
|
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
|
775 | purple_imgstore_unref(old_img); |
|
16674
95bfc8f3775c
Fix assertion when creating a new account.
Daniel Atallah <datallah@pidgin.im>
parents:
16657
diff
changeset
|
776 | else if (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
|
777 | { |
|
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
|
778 | /* 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
|
779 | * 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
|
780 | * 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
|
781 | 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
|
782 | } |
|
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
|
783 | 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
|
784 | |
|
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
|
785 | 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
|
786 | } |
|
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
|
787 | |
|
16677
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
788 | time_t |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
789 | purple_buddy_icons_get_account_icon_timestamp(PurpleAccount *account) |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
790 | { |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
791 | time_t ret; |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
792 | |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
793 | g_return_val_if_fail(account != NULL, 0); |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
794 | |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
795 | ret = purple_account_get_int(account, "buddy_icon_timestamp", 0); |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
796 | |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
797 | /* This deals with migration cases. */ |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
798 | if (ret == 0 && purple_account_get_string(account, "buddy_icon", NULL) != NULL) |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
799 | { |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
800 | ret = time(NULL); |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
801 | purple_account_set_int(account, "buddy_icon_timestamp", ret); |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
802 | } |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
803 | |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
804 | return ret; |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
805 | } |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
806 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
807 | gboolean |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
808 | purple_buddy_icons_node_has_custom_icon(PurpleBlistNode *node) |
|
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 | { |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
810 | g_return_val_if_fail(node != NULL, FALSE); |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
811 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
812 | return (purple_blist_node_get_string(node, "custom_buddy_icon") != NULL); |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
813 | } |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
814 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
815 | PurpleStoredImage * |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
816 | purple_buddy_icons_node_find_custom_icon(PurpleBlistNode *node) |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
817 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
818 | char *path; |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
819 | size_t len; |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
820 | guchar *data; |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
821 | PurpleStoredImage *img; |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
822 | const char *custom_icon_file, *dirname; |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
823 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
824 | g_return_val_if_fail(node != 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
|
825 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
826 | if ((img = g_hash_table_lookup(pointer_icon_cache, node))) |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
827 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
828 | 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
|
829 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
830 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
831 | custom_icon_file = purple_blist_node_get_string(node, |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
832 | "custom_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
|
833 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
834 | 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
|
835 | 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
|
836 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
837 | 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
|
838 | 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
|
839 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
840 | 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
|
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 | g_free(path); |
|
29234
1d444b1479d7
Fix a crash when setting a buddyicon.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27783
diff
changeset
|
843 | img = purple_buddy_icons_node_set_custom_icon(node, data, len); |
|
1d444b1479d7
Fix a crash when setting a buddyicon.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27783
diff
changeset
|
844 | return purple_imgstore_ref(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
|
845 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
846 | 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
|
847 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
848 | 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
|
849 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
850 | |
|
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
|
851 | PurpleStoredImage * |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
852 | purple_buddy_icons_node_set_custom_icon(PurpleBlistNode *node, |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
853 | guchar *icon_data, size_t icon_len) |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
854 | { |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
855 | char *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
|
856 | 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
|
857 | PurpleStoredImage *img = NULL; |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
858 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
859 | g_return_val_if_fail(node != 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
|
860 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
861 | if (!PURPLE_BLIST_NODE_IS_CONTACT(node) && |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
862 | !PURPLE_BLIST_NODE_IS_CHAT(node) && |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
863 | !PURPLE_BLIST_NODE_IS_GROUP(node)) { |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
864 | return NULL; |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
865 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
866 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
867 | old_img = g_hash_table_lookup(pointer_icon_cache, node); |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
868 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
869 | if (icon_data != NULL && icon_len > 0) { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
870 | 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
|
871 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
872 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
873 | old_icon = g_strdup(purple_blist_node_get_string(node, |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
874 | "custom_buddy_icon")); |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
875 | 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
|
876 | const char *filename = purple_imgstore_get_filename(img); |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
877 | purple_blist_node_set_string(node, "custom_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
|
878 | filename); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
879 | ref_filename(filename); |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
880 | } else { |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
881 | purple_blist_node_remove_setting(node, "custom_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
|
882 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
883 | 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
|
884 | |
|
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
|
885 | if (img) |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
886 | g_hash_table_insert(pointer_icon_cache, node, img); |
|
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
|
887 | else |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
888 | g_hash_table_remove(pointer_icon_cache, node); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
889 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
890 | if (PURPLE_BLIST_NODE_IS_CONTACT(node)) { |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
891 | PurpleBlistNode *child; |
|
24955
77727fac30c6
Finish off the libpurple updates for the hidden blist structs
Gary Kramlich <grim@reaperworld.com>
parents:
24569
diff
changeset
|
892 | for (child = purple_blist_node_get_first_child(node); |
|
77727fac30c6
Finish off the libpurple updates for the hidden blist structs
Gary Kramlich <grim@reaperworld.com>
parents:
24569
diff
changeset
|
893 | child; |
|
77727fac30c6
Finish off the libpurple updates for the hidden blist structs
Gary Kramlich <grim@reaperworld.com>
parents:
24569
diff
changeset
|
894 | child = purple_blist_node_get_sibling_next(child)) |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
895 | { |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
896 | PurpleBuddy *buddy; |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
897 | PurpleConversation *conv; |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
898 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
899 | if (!PURPLE_BLIST_NODE_IS_BUDDY(child)) |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
900 | continue; |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
901 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
902 | buddy = (PurpleBuddy *)child; |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
903 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
904 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, purple_buddy_get_name(buddy), purple_buddy_get_account(buddy)); |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
905 | if (conv) |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
906 | purple_conversation_update(conv, PURPLE_CONV_UPDATE_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
|
907 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
908 | /* Is this call necessary anymore? Can the buddies |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
909 | * themselves need updating when the custom buddy |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
910 | * icon changes? */ |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
911 | purple_blist_update_node_icon((PurpleBlistNode*)buddy); |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
912 | } |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
913 | } else if (PURPLE_BLIST_NODE_IS_CHAT(node)) { |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
914 | PurpleConversation *conv = NULL; |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
915 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
916 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, purple_chat_get_name((PurpleChat*)node), purple_chat_get_account((PurpleChat*)node)); |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
917 | if (conv) { |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
918 | purple_conversation_update(conv, PURPLE_CONV_UPDATE_ICON); |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
919 | } |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
920 | } |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
921 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
922 | purple_blist_update_node_icon(node); |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
923 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
924 | if (old_img) { |
|
16533
91e3e84b05f2
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@pidgin.im>
parents:
16532
diff
changeset
|
925 | purple_imgstore_unref(old_img); |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
926 | } else if (old_icon) { |
|
16533
91e3e84b05f2
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@pidgin.im>
parents:
16532
diff
changeset
|
927 | /* 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
|
928 | * 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
|
929 | * 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
|
930 | 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
|
931 | } |
|
91e3e84b05f2
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@pidgin.im>
parents:
16532
diff
changeset
|
932 | 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
|
933 | |
|
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
|
934 | 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
|
935 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
936 | |
|
23285
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
937 | PurpleStoredImage * |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
938 | purple_buddy_icons_node_set_custom_icon_from_file(PurpleBlistNode *node, |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
939 | const gchar *filename) |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
940 | { |
|
24273
f5b589130c88
Don't try to read data from a NULL filename in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23285
diff
changeset
|
941 | size_t len = 0; |
|
f5b589130c88
Don't try to read data from a NULL filename in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23285
diff
changeset
|
942 | guchar *data = NULL; |
|
23285
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
943 | |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
944 | g_return_val_if_fail(node != NULL, NULL); |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
945 | |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
946 | if (!PURPLE_BLIST_NODE_IS_CONTACT(node) && |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
947 | !PURPLE_BLIST_NODE_IS_CHAT(node) && |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
948 | !PURPLE_BLIST_NODE_IS_GROUP(node)) { |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
949 | return NULL; |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
950 | } |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
951 | |
|
24273
f5b589130c88
Don't try to read data from a NULL filename in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23285
diff
changeset
|
952 | if (filename != NULL) { |
|
f5b589130c88
Don't try to read data from a NULL filename in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23285
diff
changeset
|
953 | if (!read_icon_file(filename, &data, &len)) { |
|
f5b589130c88
Don't try to read data from a NULL filename in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23285
diff
changeset
|
954 | return NULL; |
|
f5b589130c88
Don't try to read data from a NULL filename in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23285
diff
changeset
|
955 | } |
|
23285
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
956 | } |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
957 | |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
958 | return purple_buddy_icons_node_set_custom_icon(node, data, len); |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
959 | } |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
960 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
961 | gboolean |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
962 | purple_buddy_icons_has_custom_icon(PurpleContact *contact) |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
963 | { |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
964 | return purple_buddy_icons_node_has_custom_icon((PurpleBlistNode*)contact); |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
965 | } |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
966 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
967 | PurpleStoredImage * |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
968 | purple_buddy_icons_find_custom_icon(PurpleContact *contact) |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
969 | { |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
970 | return purple_buddy_icons_node_find_custom_icon((PurpleBlistNode*)contact); |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
971 | } |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
972 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
973 | PurpleStoredImage * |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
974 | purple_buddy_icons_set_custom_icon(PurpleContact *contact, guchar *icon_data, |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
975 | size_t icon_len) |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
976 | { |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
977 | return purple_buddy_icons_node_set_custom_icon((PurpleBlistNode*)contact, icon_data, icon_len); |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
978 | } |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
979 | |
|
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
|
980 | void |
|
16696
450ba3bd5b63
The GNOME coding guidelines recommend prefixing internal symbols with an underscore.
Richard Laager <rlaager@pidgin.im>
parents:
16690
diff
changeset
|
981 | _purple_buddy_icon_set_old_icons_dir(const char *dirname) |
|
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
|
982 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
983 | 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
|
984 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
985 | |
|
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 | static void |
|
16614
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
987 | delete_buddy_icon_settings(PurpleBlistNode *node, const char *setting_name) |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
988 | { |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
989 | purple_blist_node_remove_setting(node, setting_name); |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
990 | |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
24955
diff
changeset
|
991 | if (purple_strequal(setting_name, "buddy_icon")) |
|
16614
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
992 | { |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
993 | purple_blist_node_remove_setting(node, "avatar_hash"); |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
994 | purple_blist_node_remove_setting(node, "icon_checksum"); |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
995 | } |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
996 | } |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
997 | |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
998 | static void |
|
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
|
999 | 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
|
1000 | 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
|
1001 | { |
|
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 | 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
|
1003 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1004 | 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
|
1005 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1006 | 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
|
1007 | 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
|
1008 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1009 | 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
|
1010 | 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
|
1011 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1012 | 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
|
1013 | |
|
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 | 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
|
1015 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1016 | 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
|
1017 | 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
|
1018 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1019 | 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
|
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 | 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
|
1022 | 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
|
1023 | 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
|
1024 | char *new_filename; |
|
9747
5c89f93ad4dc
[gaim-migrate @ 10613]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9396
diff
changeset
|
1025 | |
|
16680
3a672630db5a
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@pidgin.im>
parents:
16679
diff
changeset
|
1026 | if (!read_icon_file(path, &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
|
1027 | { |
|
16680
3a672630db5a
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@pidgin.im>
parents:
16679
diff
changeset
|
1028 | g_free(path); |
|
3a672630db5a
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@pidgin.im>
parents:
16679
diff
changeset
|
1029 | delete_buddy_icon_settings(node, setting_name); |
|
3a672630db5a
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@pidgin.im>
parents:
16679
diff
changeset
|
1030 | return; |
|
3a672630db5a
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@pidgin.im>
parents:
16679
diff
changeset
|
1031 | } |
|
3a672630db5a
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@pidgin.im>
parents:
16679
diff
changeset
|
1032 | |
|
3a672630db5a
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@pidgin.im>
parents:
16679
diff
changeset
|
1033 | if (icon_data == NULL || icon_len <= 0) |
|
3a672630db5a
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@pidgin.im>
parents:
16679
diff
changeset
|
1034 | { |
|
3a672630db5a
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@pidgin.im>
parents:
16679
diff
changeset
|
1035 | /* This really applies to the icon_len check. |
|
3a672630db5a
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@pidgin.im>
parents:
16679
diff
changeset
|
1036 | * icon_data should never be NULL if |
|
3a672630db5a
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@pidgin.im>
parents:
16679
diff
changeset
|
1037 | * read_icon_file() returns TRUE. */ |
|
3a672630db5a
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@pidgin.im>
parents:
16679
diff
changeset
|
1038 | purple_debug_error("buddyicon", "Empty buddy icon file: %s\n", path); |
|
16614
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
1039 | delete_buddy_icon_settings(node, setting_name); |
|
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
|
1040 | 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
|
1041 | 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
|
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 | 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
|
1045 | |
|
18101
3ce21b5a182c
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@pidgin.im>
parents:
17033
diff
changeset
|
1046 | new_filename = purple_util_get_image_filename(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
|
1047 | 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
|
1048 | { |
|
16680
3a672630db5a
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@pidgin.im>
parents:
16679
diff
changeset
|
1049 | purple_debug_error("buddyicon", |
|
3a672630db5a
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@pidgin.im>
parents:
16679
diff
changeset
|
1050 | "New icon filename is NULL. This should never happen! " |
|
3a672630db5a
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@pidgin.im>
parents:
16679
diff
changeset
|
1051 | "The old filename was: %s\n", path); |
|
16614
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
1052 | delete_buddy_icon_settings(node, setting_name); |
|
16680
3a672630db5a
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@pidgin.im>
parents:
16679
diff
changeset
|
1053 | g_return_if_reached(); |
|
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
|
1054 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1055 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1056 | 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
|
1057 | 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
|
1058 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1059 | 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
|
1060 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1061 | purple_debug_error("buddyicon", "Error writing %s: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20242
diff
changeset
|
1062 | path, g_strerror(errno)); |
|
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
|
1063 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1064 | 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
|
1065 | 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
|
1066 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1067 | 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
|
1068 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1069 | 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
|
1070 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1071 | purple_debug_error("buddyicon", "Unable to create file %s: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20242
diff
changeset
|
1072 | path, g_strerror(errno)); |
|
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
|
1073 | 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
|
1074 | g_free(path); |
|
16614
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
1075 | |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
1076 | delete_buddy_icon_settings(node, setting_name); |
|
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
|
1077 | 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
|
1078 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1079 | 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
|
1080 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1081 | 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
|
1082 | 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
|
1083 | 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
|
1084 | 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
|
1085 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1086 | 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
|
1087 | |
|
25859
b42be7bb9dac
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <darkrain42@pidgin.im>
parents:
24955
diff
changeset
|
1088 | if (purple_strequal(setting_name, "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
|
1089 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
1090 | 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
|
1091 | |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
1092 | 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
|
1093 | 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
|
1094 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
1095 | 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
|
1096 | 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
|
1097 | } |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
1098 | } |
|
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
|
1099 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1100 | 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
|
1101 | { |
|
16680
3a672630db5a
Add more error checking to the buddy icon migration code.
Richard Laager <rlaager@pidgin.im>
parents:
16679
diff
changeset
|
1102 | purple_debug_error("buddyicon", "Old icon file doesn't exist: %s\n", path); |
|
16614
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
1103 | delete_buddy_icon_settings(node, setting_name); |
|
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
|
1104 | 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
|
1105 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1106 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1107 | |
|
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 | void |
|
16696
450ba3bd5b63
The GNOME coding guidelines recommend prefixing internal symbols with an underscore.
Richard Laager <rlaager@pidgin.im>
parents:
16690
diff
changeset
|
1109 | _purple_buddy_icons_account_loaded_cb() |
|
16565
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1110 | { |
|
16567
4d79ee03965d
This is probably needed to compile.
Richard Laager <rlaager@pidgin.im>
parents:
16566
diff
changeset
|
1111 | const char *dirname = purple_buddy_icons_get_cache_dir(); |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
1112 | GList *cur; |
|
16565
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1113 | |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1114 | for (cur = purple_accounts_get_all(); cur != NULL; cur = cur->next) |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1115 | { |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1116 | PurpleAccount *account = cur->data; |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1117 | const char *account_icon_file = purple_account_get_string(account, "buddy_icon", NULL); |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1118 | |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1119 | if (account_icon_file != NULL) |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1120 | { |
|
16568
b26c36d6cf2d
I really shouldn't commit before compiling.
Richard Laager <rlaager@pidgin.im>
parents:
16567
diff
changeset
|
1121 | char *path = g_build_filename(dirname, account_icon_file, NULL); |
|
b26c36d6cf2d
I really shouldn't commit before compiling.
Richard Laager <rlaager@pidgin.im>
parents:
16567
diff
changeset
|
1122 | if (!g_file_test(path, G_FILE_TEST_EXISTS)) |
|
16565
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1123 | { |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1124 | purple_account_set_string(account, "buddy_icon", NULL); |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1125 | } else { |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1126 | ref_filename(account_icon_file); |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1127 | } |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1128 | g_free(path); |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1129 | } |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1130 | } |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1131 | } |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1132 | |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1133 | void |
|
16696
450ba3bd5b63
The GNOME coding guidelines recommend prefixing internal symbols with an underscore.
Richard Laager <rlaager@pidgin.im>
parents:
16690
diff
changeset
|
1134 | _purple_buddy_icons_blist_loaded_cb() |
|
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
|
1135 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1136 | 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
|
1137 | 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
|
1138 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1139 | /* 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
|
1140 | 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
|
1141 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1142 | 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
|
1143 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1144 | 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
|
1145 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1146 | 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
|
1147 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1148 | 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
|
1149 | "Unable to create directory %s: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20242
diff
changeset
|
1150 | dirname, g_strerror(errno)); |
| 9396 | 1151 | } |
| 1152 | } | |
| 1153 | } | |
| 1154 | ||
|
16657
63e53570702c
Whitespace fix from patch in ticket #383
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16632
diff
changeset
|
1155 | while (node != 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
|
1156 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1157 | 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
|
1158 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1159 | 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
|
1160 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1161 | 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
|
1162 | 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
|
1163 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1164 | 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
|
1165 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1166 | 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
|
1167 | "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
|
1168 | 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
|
1169 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1170 | 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
|
1171 | { |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
1172 | char *path = g_build_filename(dirname, filename, NULL); |
|
16566
98c93d211a45
Fix a small-but-serious bug with the code to ref the buddy icons at load.
Richard Laager <rlaager@pidgin.im>
parents:
16565
diff
changeset
|
1173 | 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
|
1174 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1175 | 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
|
1176 | "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
|
1177 | 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
|
1178 | "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
|
1179 | } |
|
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
|
1180 | 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
|
1181 | 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
|
1182 | 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
|
1183 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1184 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1185 | } |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
1186 | else if (PURPLE_BLIST_NODE_IS_CONTACT(node) || |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
1187 | PURPLE_BLIST_NODE_IS_CHAT(node) || |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
1188 | PURPLE_BLIST_NODE_IS_GROUP(node)) |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1189 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1190 | 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
|
1191 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1192 | 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
|
1193 | 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
|
1194 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1195 | 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
|
1196 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1197 | 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
|
1198 | "custom_buddy_icon", |
|
16615
179e7ea58483
Minor whitespace tweak.
Richard Laager <rlaager@pidgin.im>
parents:
16614
diff
changeset
|
1199 | dirname, 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
|
1200 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1201 | 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
|
1202 | { |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
1203 | 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
|
1204 | 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
|
1205 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1206 | 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
|
1207 | "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
|
1208 | } |
|
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
|
1209 | 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
|
1210 | 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
|
1211 | 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
|
1212 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1213 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1214 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1215 | node = purple_blist_node_next(node, TRUE); |
|
16657
63e53570702c
Whitespace fix from patch in ticket #383
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16632
diff
changeset
|
1216 | } |
| 6846 | 1217 | } |
| 1218 | ||
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1219 | void |
| 15884 | 1220 | purple_buddy_icons_set_caching(gboolean caching) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1221 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1222 | icon_caching = caching; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1223 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1224 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1225 | gboolean |
| 15884 | 1226 | purple_buddy_icons_is_caching(void) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1227 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1228 | return icon_caching; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1229 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1230 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1231 | void |
| 15884 | 1232 | purple_buddy_icons_set_cache_dir(const char *dir) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1233 | { |
|
10811
6b7ac5a9dd35
[gaim-migrate @ 12464]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
1234 | g_return_if_fail(dir != NULL); |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1235 | |
|
13934
c554909e9ff6
[gaim-migrate @ 16342]
Mark Doliner <markdoliner@pidgin.im>
parents:
13555
diff
changeset
|
1236 | g_free(cache_dir); |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1237 | cache_dir = g_strdup(dir); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1238 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1239 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1240 | const char * |
| 15884 | 1241 | purple_buddy_icons_get_cache_dir(void) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1242 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1243 | return cache_dir; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1244 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1245 | |
| 6846 | 1246 | void * |
| 15884 | 1247 | purple_buddy_icons_get_handle() |
| 6846 | 1248 | { |
| 1249 | static int handle; | |
| 1250 | ||
| 1251 | return &handle; | |
| 1252 | } | |
| 1253 | ||
| 1254 | void | |
| 15884 | 1255 | purple_buddy_icons_init() |
| 6846 | 1256 | { |
| 1257 | account_cache = g_hash_table_new_full( | |
| 1258 | g_direct_hash, g_direct_equal, | |
| 1259 | NULL, (GFreeFunc)g_hash_table_destroy); | |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1260 | |
|
16669
69babfdf63e6
19:00:43 Ka-Hing Cheung (khc): rlaager: shouldn't we give g_free as the key free function for icon_data_cache?
Richard Laager <rlaager@pidgin.im>
parents:
16657
diff
changeset
|
1261 | icon_data_cache = g_hash_table_new_full(g_str_hash, g_str_equal, |
|
69babfdf63e6
19:00:43 Ka-Hing Cheung (khc): rlaager: shouldn't we give g_free as the key free function for icon_data_cache?
Richard Laager <rlaager@pidgin.im>
parents:
16657
diff
changeset
|
1262 | g_free, 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
|
1263 | 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
|
1264 | 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
|
1265 | 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
|
1266 | |
| 38213 | 1267 | if (!cache_dir) |
| 1268 | 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
|
1269 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1270 | 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
|
1271 | 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
|
1272 | G_CALLBACK(image_deleting_cb), NULL); |
| 6846 | 1273 | } |
| 1274 | ||
| 1275 | void | |
| 15884 | 1276 | purple_buddy_icons_uninit() |
| 6846 | 1277 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1278 | 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
|
1279 | |
| 6846 | 1280 | 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
|
1281 | 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
|
1282 | 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
|
1283 | 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
|
1284 | g_free(old_icons_dir); |
|
26744
ac7a89587cad
Various libpurple uninit memory cleanups.
Nick Hebner <hebnern@gmail.com>
parents:
25888
diff
changeset
|
1285 | g_free(cache_dir); |
|
29296
c351bc2db920
Zero freed memory to avoid a crash on re-init.
Ludovico Cavedon <ludovico.cavedon@gmail.com>
parents:
29234
diff
changeset
|
1286 | |
|
c351bc2db920
Zero freed memory to avoid a crash on re-init.
Ludovico Cavedon <ludovico.cavedon@gmail.com>
parents:
29234
diff
changeset
|
1287 | cache_dir = NULL; |
|
c351bc2db920
Zero freed memory to avoid a crash on re-init.
Ludovico Cavedon <ludovico.cavedon@gmail.com>
parents:
29234
diff
changeset
|
1288 | old_icons_dir = NULL; |
| 6846 | 1289 | } |
| 10483 | 1290 | |
| 15884 | 1291 | void purple_buddy_icon_get_scale_size(PurpleBuddyIconSpec *spec, int *width, int *height) |
| 10483 | 1292 | { |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1293 | int new_width, new_height; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1294 | |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1295 | new_width = *width; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1296 | new_height = *height; |
|
10523
ef52a88a8512
[gaim-migrate @ 11840]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10483
diff
changeset
|
1297 | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1298 | if (*width < spec->min_width) |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1299 | new_width = spec->min_width; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1300 | else if (*width > spec->max_width) |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1301 | new_width = spec->max_width; |
| 10483 | 1302 | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1303 | if (*height < spec->min_height) |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1304 | new_height = spec->min_height; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1305 | else if (*height > spec->max_height) |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1306 | new_height = spec->max_height; |
|
10523
ef52a88a8512
[gaim-migrate @ 11840]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10483
diff
changeset
|
1307 | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1308 | /* preserve aspect ratio */ |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1309 | if ((double)*height * (double)new_width > |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1310 | (double)*width * (double)new_height) { |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1311 | new_width = 0.5 + (double)*width * (double)new_height / (double)*height; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1312 | } else { |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1313 | new_height = 0.5 + (double)*height * (double)new_width / (double)*width; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1314 | } |
|
10523
ef52a88a8512
[gaim-migrate @ 11840]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10483
diff
changeset
|
1315 | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1316 | *width = new_width; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1317 | *height = new_height; |
| 10483 | 1318 | } |