Sun, 09 Aug 2015 22:42:34 -0400
Prevents a segfault caused by a null filename. This caused frequent but nondeterministic crashes on startup when run on OpenBSD. Buddy icons seem to render fine when this check is added.
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
1 | /* purple |
| 6846 | 2 | * |
| 15884 | 3 | * Purple is the legal property of its developers, whose names are too numerous |
| 8046 | 4 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 5 | * source distribution. | |
| 6846 | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify | |
| 8 | * it under the terms of the GNU General Public License as published by | |
| 9 | * the Free Software Foundation; either version 2 of the License, or | |
| 10 | * (at your option) any later version. | |
| 11 | * | |
| 12 | * This program is distributed in the hope that it will be useful, | |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | * GNU General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU General Public License | |
| 18 | * 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
|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 6846 | 20 | */ |
|
24569
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
24273
diff
changeset
|
21 | #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
|
22 | |
| 6846 | 23 | #include "internal.h" |
| 24 | #include "buddyicon.h" | |
| 25 | #include "conversation.h" | |
|
13555
b4d6a5e6853a
[gaim-migrate @ 15932]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12996
diff
changeset
|
26 | #include "dbus-maybe.h" |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
27 | #include "debug.h" |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
28 | #include "image.h" |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
29 | #include "util.h" |
| 6846 | 30 | |
|
34832
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
31 | /* NOTE: Instances of this struct are allocated without zeroing the memory, so |
|
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
32 | * NOTE: be sure to update purple_buddy_icon_new() if you add members. */ |
|
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
33 | struct _PurpleBuddyIcon |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
34 | { |
|
35458
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
35 | PurpleAccount *account; /* The account the user is on. */ |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
36 | PurpleImage *img; /* The image containing |
|
35458
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
37 | the icon data. */ |
|
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
38 | char *username; /* The username the icon belongs to. */ |
|
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
39 | char *checksum; /* The protocol checksum. */ |
|
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
40 | unsigned int ref_count; /* The buddy icon reference count. */ |
|
34832
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
41 | }; |
|
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
|
42 | |
|
35458
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
43 | /* |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
44 | * This is the big grand daddy hash table that contains references to |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
45 | * everybody's buddy icons. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
46 | * |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
47 | * Key is a PurpleAccount. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
48 | * Value is another hash table, usually referred to as "icon_cache." |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
49 | * For this inner hash table: |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
50 | * Key is the username of the buddy whose icon is being stored. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
51 | * Value is the PurpleBuddyIcon for this buddy. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
52 | */ |
| 6846 | 53 | static GHashTable *account_cache = NULL; |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
54 | |
|
35458
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
55 | /* |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
56 | * This hash table contains a bunch of PurpleImages that are |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
57 | * shared across all accounts. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
58 | * |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
59 | * Key is the filename for this image as constructed by |
|
35837
528ddb11791c
Drop purple_util_get_image_extension and purple_util_get_image_filename
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35809
diff
changeset
|
60 | * purple_image_generate_filename(). So it is the base16 encoded |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
61 | * sha-1 hash plus an appropriate file extension. For example: |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
62 | * "0f4972d17d1e70e751c43c90c948e72efbff9796.gif" |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
63 | * |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
64 | * The value is a PurpleImage containing the icon data. These images are |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
65 | * reference counted, and when the count reaches 0 we remove the image from |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
66 | * the hash table (but it might still be saved on disk, if the icon is being |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
67 | * used by offline accounts or some such). |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
68 | */ |
|
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
|
69 | static GHashTable *icon_data_cache = NULL; |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
70 | |
|
35458
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
71 | /* |
| 33664 | 72 | * This hash table contains reference counts for how many times each |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
73 | * icon in the ~/.purple/icons/ directory is being used. It's pretty |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
74 | * crazy. It maintains the reference count across sessions, too, so |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
75 | * if you exit Pidgin then this hash table is reconstructed the next |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
76 | * time Pidgin starts. |
|
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 | * Key is the filename for this image as constructed by |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
79 | * purple_image_generate_filename(). So it is the base16 encoded |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
80 | * sha-1 hash plus an appropriate file extension. For example: |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
81 | * "0f4972d17d1e70e751c43c90c948e72efbff9796.gif" |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
82 | * |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
83 | * 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
|
84 | * 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
|
85 | * 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
|
86 | * will be six. When this reference count reaches 0 the icon will |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
87 | * be deleted from disk. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
88 | */ |
|
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
|
89 | 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
|
90 | |
|
35458
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
91 | /* |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
92 | * This hash table is used for both custom buddy icons on PurpleBlistNodes and |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
93 | * account icons. |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
94 | */ |
|
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
|
95 | 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
|
96 | |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
97 | static char *cache_dir = NULL; |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
98 | |
|
35458
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
99 | /* "Should icons be cached to disk?" */ |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
100 | static gboolean icon_caching = TRUE; |
| 6846 | 101 | |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
102 | static void delete_buddy_icon_settings(PurpleBlistNode *node, const char *setting_name); |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
103 | |
|
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 | * Begin functions for dealing with the on-disk icon cache |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
106 | */ |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
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 | 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
|
109 | 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
|
110 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
111 | 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
|
112 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
113 | 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
|
114 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
115 | 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
|
116 | |
|
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 | 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
|
118 | 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
|
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 | |
|
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 | 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
|
122 | 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
|
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 | 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
|
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 | 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
|
127 | 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
|
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 | 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
|
130 | |
|
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 | 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
|
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 | 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
|
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 | 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
|
136 | { |
|
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 | 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
|
138 | 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
|
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 | } |
|
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 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
142 | static const gchar * |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
143 | image_get_filename(PurpleImage *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
|
144 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
145 | return g_object_get_data(G_OBJECT(img), "purple-buddyicon-filename"); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
146 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
147 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
148 | static void |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
149 | purple_buddy_icon_data_cache(PurpleImage *img) |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
150 | { |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
151 | const gchar *dirname, *filename; |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
152 | gchar *path; |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
153 | |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
154 | g_return_if_fail(PURPLE_IS_IMAGE(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
|
155 | |
|
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
|
156 | 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
|
157 | 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
|
158 | |
| 33664 | 159 | dirname = purple_buddy_icons_get_cache_dir(); |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
160 | filename = image_get_filename(img); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
161 | g_return_if_fail(filename != NULL); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
162 | 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
|
163 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
164 | 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
|
165 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
166 | purple_debug_info("buddyicon", "creating icon cache directory"); |
|
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
|
167 | |
|
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 | 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
|
169 | { |
|
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 | purple_debug_error("buddyicon", |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
171 | "unable to create directory %s: %s", |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
172 | dirname, g_strerror(errno)); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
173 | return; |
|
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 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
177 | if (!purple_image_save(img, path)) |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
178 | purple_debug_error("buddyicon", "failed to save icon %s", 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
|
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 | |
| 33664 | 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 |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
229 | image_deleting_cb(gpointer _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
|
230 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
231 | PurpleImage *img; |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
232 | gchar *filename = _filename; |
|
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 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
234 | img = g_hash_table_lookup(icon_data_cache, filename); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
235 | purple_buddy_icon_data_uncache_file(filename); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
236 | 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
|
237 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
238 | /* We could make this O(1) by using another hash table, but |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
239 | * this is probably good enough. */ |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
240 | g_hash_table_foreach_remove(pointer_icon_cache, value_equals, (gpointer)img); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
241 | |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
242 | g_free(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
|
243 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
244 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
245 | static PurpleImage * |
| 33664 | 246 | purple_buddy_icon_data_new(guchar *icon_data, size_t 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
|
247 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
248 | PurpleImage *newimg, *oldimg; |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
249 | const gchar *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 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
251 | g_return_val_if_fail(icon_data != NULL, NULL); |
| 33664 | 252 | g_return_val_if_fail(icon_len > 0, 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
|
253 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
254 | newimg = purple_image_new_from_data(icon_data, icon_len); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
255 | filename = purple_image_generate_filename(newimg); |
|
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
|
256 | |
|
37228
7e57fa4513f4
Prevents a segfault caused by a null filename. This caused frequent but nondeterministic crashes on startup when run on OpenBSD. Buddy icons seem to render fine when this check is added.
Michael McConville <mmcconville@mykolab.com>
parents:
37135
diff
changeset
|
257 | /* TODO: Why is this function called for buddies without icons? If this is |
|
7e57fa4513f4
Prevents a segfault caused by a null filename. This caused frequent but nondeterministic crashes on startup when run on OpenBSD. Buddy icons seem to render fine when this check is added.
Michael McConville <mmcconville@mykolab.com>
parents:
37135
diff
changeset
|
258 | * intended, should the filename be null? |
|
7e57fa4513f4
Prevents a segfault caused by a null filename. This caused frequent but nondeterministic crashes on startup when run on OpenBSD. Buddy icons seem to render fine when this check is added.
Michael McConville <mmcconville@mykolab.com>
parents:
37135
diff
changeset
|
259 | */ |
|
7e57fa4513f4
Prevents a segfault caused by a null filename. This caused frequent but nondeterministic crashes on startup when run on OpenBSD. Buddy icons seem to render fine when this check is added.
Michael McConville <mmcconville@mykolab.com>
parents:
37135
diff
changeset
|
260 | if (filename != NULL) { |
|
7e57fa4513f4
Prevents a segfault caused by a null filename. This caused frequent but nondeterministic crashes on startup when run on OpenBSD. Buddy icons seem to render fine when this check is added.
Michael McConville <mmcconville@mykolab.com>
parents:
37135
diff
changeset
|
261 | oldimg = g_hash_table_lookup(icon_data_cache, filename); |
|
7e57fa4513f4
Prevents a segfault caused by a null filename. This caused frequent but nondeterministic crashes on startup when run on OpenBSD. Buddy icons seem to render fine when this check is added.
Michael McConville <mmcconville@mykolab.com>
parents:
37135
diff
changeset
|
262 | if (oldimg) { |
|
7e57fa4513f4
Prevents a segfault caused by a null filename. This caused frequent but nondeterministic crashes on startup when run on OpenBSD. Buddy icons seem to render fine when this check is added.
Michael McConville <mmcconville@mykolab.com>
parents:
37135
diff
changeset
|
263 | g_warn_if_fail(PURPLE_IS_IMAGE(oldimg)); |
|
7e57fa4513f4
Prevents a segfault caused by a null filename. This caused frequent but nondeterministic crashes on startup when run on OpenBSD. Buddy icons seem to render fine when this check is added.
Michael McConville <mmcconville@mykolab.com>
parents:
37135
diff
changeset
|
264 | g_object_unref(newimg); |
|
7e57fa4513f4
Prevents a segfault caused by a null filename. This caused frequent but nondeterministic crashes on startup when run on OpenBSD. Buddy icons seem to render fine when this check is added.
Michael McConville <mmcconville@mykolab.com>
parents:
37135
diff
changeset
|
265 | g_object_ref(oldimg); |
|
7e57fa4513f4
Prevents a segfault caused by a null filename. This caused frequent but nondeterministic crashes on startup when run on OpenBSD. Buddy icons seem to render fine when this check is added.
Michael McConville <mmcconville@mykolab.com>
parents:
37135
diff
changeset
|
266 | return oldimg; |
|
7e57fa4513f4
Prevents a segfault caused by a null filename. This caused frequent but nondeterministic crashes on startup when run on OpenBSD. Buddy icons seem to render fine when this check is added.
Michael McConville <mmcconville@mykolab.com>
parents:
37135
diff
changeset
|
267 | } |
|
7e57fa4513f4
Prevents a segfault caused by a null filename. This caused frequent but nondeterministic crashes on startup when run on OpenBSD. Buddy icons seem to render fine when this check is added.
Michael McConville <mmcconville@mykolab.com>
parents:
37135
diff
changeset
|
268 | |
|
7e57fa4513f4
Prevents a segfault caused by a null filename. This caused frequent but nondeterministic crashes on startup when run on OpenBSD. Buddy icons seem to render fine when this check is added.
Michael McConville <mmcconville@mykolab.com>
parents:
37135
diff
changeset
|
269 | /* This will take ownership of file and free it as needed */ |
|
7e57fa4513f4
Prevents a segfault caused by a null filename. This caused frequent but nondeterministic crashes on startup when run on OpenBSD. Buddy icons seem to render fine when this check is added.
Michael McConville <mmcconville@mykolab.com>
parents:
37135
diff
changeset
|
270 | g_hash_table_insert(icon_data_cache, g_strdup(filename), newimg); |
|
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
|
271 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
272 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
273 | g_object_set_data_full(G_OBJECT(newimg), "purple-buddyicon-filename", |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
274 | g_strdup(filename), image_deleting_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
|
275 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
276 | purple_buddy_icon_data_cache(newimg); |
|
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 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
278 | return newimg; |
|
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
|
279 | } |
|
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 | |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
281 | /* |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
282 | * End functions for dealing with the in-memory icon cache |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
283 | */ |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
284 | |
| 15884 | 285 | static PurpleBuddyIcon * |
| 286 | purple_buddy_icon_create(PurpleAccount *account, const char *username) | |
| 9396 | 287 | { |
| 15884 | 288 | PurpleBuddyIcon *icon; |
| 9396 | 289 | GHashTable *icon_cache; |
| 290 | ||
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
291 | /* 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
|
292 | * 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
|
293 | icon = g_slice_new(PurpleBuddyIcon); |
| 15884 | 294 | PURPLE_DBUS_REGISTER_POINTER(icon, PurpleBuddyIcon); |
| 9396 | 295 | |
|
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
|
296 | 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
|
297 | 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
|
298 | icon->checksum = NULL; |
|
16924
a061b2ff4cf7
Fix a reference counting bug.
Richard Laager <rlaager@pidgin.im>
parents:
16903
diff
changeset
|
299 | icon->ref_count = 1; |
| 9396 | 300 | |
| 301 | icon_cache = g_hash_table_lookup(account_cache, account); | |
| 302 | ||
| 303 | if (icon_cache == NULL) | |
| 304 | { | |
| 305 | icon_cache = g_hash_table_new(g_str_hash, g_str_equal); | |
| 306 | ||
| 307 | g_hash_table_insert(account_cache, account, icon_cache); | |
| 308 | } | |
| 309 | ||
| 310 | 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
|
311 | (char *)purple_buddy_icon_get_username(icon), icon); |
| 9396 | 312 | return icon; |
| 313 | } | |
| 314 | ||
| 15884 | 315 | PurpleBuddyIcon * |
| 316 | 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
|
317 | 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
|
318 | const char *checksum) |
| 6846 | 319 | { |
| 15884 | 320 | PurpleBuddyIcon *icon; |
| 6846 | 321 | |
| 322 | g_return_val_if_fail(account != NULL, NULL); | |
| 323 | 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
|
324 | 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
|
325 | g_return_val_if_fail(icon_len > 0, NULL); |
| 6846 | 326 | |
|
16438
64e892ac6180
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
327 | /* 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
|
328 | * sure to update it as well when members are added. */ |
| 15884 | 329 | icon = purple_buddy_icons_find(account, username); |
| 6846 | 330 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
331 | /* purple_buddy_icon_create() sets account & username */ |
| 6846 | 332 | if (icon == NULL) |
| 15884 | 333 | icon = purple_buddy_icon_create(account, username); |
| 6846 | 334 | |
|
16438
64e892ac6180
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
335 | /* 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
|
336 | * 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
|
337 | 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
|
338 | 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
|
339 | |
| 6846 | 340 | return icon; |
| 341 | } | |
| 342 | ||
| 15884 | 343 | PurpleBuddyIcon * |
| 344 | purple_buddy_icon_ref(PurpleBuddyIcon *icon) | |
| 6846 | 345 | { |
| 346 | g_return_val_if_fail(icon != NULL, NULL); | |
| 347 | ||
| 348 | icon->ref_count++; | |
| 349 | ||
| 350 | return icon; | |
| 351 | } | |
| 352 | ||
|
33665
55fcd8716546
Change purple_buddy_icon_unref to not return anything.
Mark Doliner <mark@kingant.net>
parents:
33664
diff
changeset
|
353 | void |
| 15884 | 354 | purple_buddy_icon_unref(PurpleBuddyIcon *icon) |
| 6846 | 355 | { |
|
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
|
356 | if (icon == NULL) |
|
33665
55fcd8716546
Change purple_buddy_icon_unref to not return anything.
Mark Doliner <mark@kingant.net>
parents:
33664
diff
changeset
|
357 | return; |
|
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
|
358 | |
|
33665
55fcd8716546
Change purple_buddy_icon_unref to not return anything.
Mark Doliner <mark@kingant.net>
parents:
33664
diff
changeset
|
359 | g_return_if_fail(icon->ref_count > 0); |
| 6846 | 360 | |
| 361 | icon->ref_count--; | |
| 362 | ||
| 363 | if (icon->ref_count == 0) | |
| 364 | { | |
|
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
|
365 | 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
|
366 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
367 | 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
|
368 | 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
|
369 | |
|
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 | 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
|
371 | g_free(icon->checksum); |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
372 | g_object_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
|
373 | |
|
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 | 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
|
375 | g_slice_free(PurpleBuddyIcon, icon); |
| 6846 | 376 | } |
| 377 | } | |
| 378 | ||
| 379 | void | |
| 15884 | 380 | purple_buddy_icon_update(PurpleBuddyIcon *icon) |
| 6846 | 381 | { |
|
34645
a04c721bebf1
Refactored accounts, blist, cmds and connection to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
382 | PurpleIMConversation *im; |
| 15884 | 383 | PurpleAccount *account; |
| 6846 | 384 | 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
|
385 | 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
|
386 | GSList *buddies; |
| 6846 | 387 | |
| 388 | g_return_if_fail(icon != NULL); | |
| 389 | ||
| 15884 | 390 | account = purple_buddy_icon_get_account(icon); |
| 391 | username = purple_buddy_icon_get_username(icon); | |
| 6846 | 392 | |
|
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
|
393 | /* 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
|
394 | * 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
|
395 | * 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
|
396 | * 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
|
397 | * 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
|
398 | 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
|
399 | |
|
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
|
400 | /* Ensure that icon remains valid throughout */ |
|
33769
96f89e35d24d
Fix various "Dereference before null check" issues
Daniel Atallah <datallah@pidgin.im>
parents:
29296
diff
changeset
|
401 | 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
|
402 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34699
diff
changeset
|
403 | buddies = purple_blist_find_buddies(account, username); |
|
16863
b98303c15033
Change a few functions to free a linked list while iterating through
Mark Doliner <markdoliner@pidgin.im>
parents:
16775
diff
changeset
|
404 | while (buddies != NULL) |
| 6846 | 405 | { |
|
16863
b98303c15033
Change a few functions to free a linked list while iterating through
Mark Doliner <markdoliner@pidgin.im>
parents:
16775
diff
changeset
|
406 | 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
|
407 | char *old_icon; |
| 6846 | 408 | |
|
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
|
409 | purple_buddy_set_icon(buddy, icon_to_set); |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
410 | old_icon = g_strdup(purple_blist_node_get_string((PurpleBlistNode *)buddy, |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
411 | "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
|
412 | 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
|
413 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
414 | const char *filename = image_get_filename(icon->img); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
415 | g_warn_if_fail(filename != NULL); |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
416 | purple_blist_node_set_string((PurpleBlistNode *)buddy, |
|
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
|
417 | "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
|
418 | 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
|
419 | |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
420 | 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
|
421 | { |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
422 | purple_blist_node_set_string((PurpleBlistNode *)buddy, |
|
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
|
423 | "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
|
424 | 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
|
425 | } |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
426 | 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
|
427 | { |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
428 | purple_blist_node_remove_setting((PurpleBlistNode *)buddy, |
|
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
|
429 | "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
|
430 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
431 | 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
|
432 | } |
|
17033
27d9faa34ad1
Patch from ticket #819 from vampire
Richard Laager <rlaager@pidgin.im>
parents:
16924
diff
changeset
|
433 | 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
|
434 | { |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
435 | purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "buddy_icon"); |
|
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
436 | 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
|
437 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
438 | 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
|
439 | 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
|
440 | |
|
b98303c15033
Change a few functions to free a linked list while iterating through
Mark Doliner <markdoliner@pidgin.im>
parents:
16775
diff
changeset
|
441 | buddies = g_slist_delete_link(buddies, buddies); |
| 6846 | 442 | } |
| 443 | ||
|
34645
a04c721bebf1
Refactored accounts, blist, cmds and connection to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
444 | im = purple_conversations_find_im_with_account(username, account); |
| 6846 | 445 | |
|
34645
a04c721bebf1
Refactored accounts, blist, cmds and connection to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
446 | if (im != NULL) |
|
a04c721bebf1
Refactored accounts, blist, cmds and connection to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
447 | purple_im_conversation_set_icon(im, icon_to_set); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
448 | |
|
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
|
449 | /* icon's refcount was incremented above */ |
|
33788
83e5594ced88
Fix a few bogus NULL checks
Daniel Atallah <datallah@pidgin.im>
parents:
33769
diff
changeset
|
450 | purple_buddy_icon_unref(icon); |
|
11040
37e247d18e78
[gaim-migrate @ 12940]
Richard Laager <rlaager@pidgin.im>
parents:
11033
diff
changeset
|
451 | } |
|
37e247d18e78
[gaim-migrate @ 12940]
Richard Laager <rlaager@pidgin.im>
parents:
11033
diff
changeset
|
452 | |
| 6846 | 453 | 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
|
454 | 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
|
455 | size_t len, const char *checksum) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
456 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
457 | PurpleImage *old_img; |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
458 | |
|
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
|
459 | g_return_if_fail(icon != NULL); |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
460 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
461 | 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
|
462 | icon->img = NULL; |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
463 | |
|
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
|
464 | if (data != NULL) |
|
16544
945caa0d6436
Kill some compiler warnings and TODOs of mine.
Richard Laager <rlaager@pidgin.im>
parents:
16539
diff
changeset
|
465 | { |
|
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
|
466 | if (len > 0) |
| 33664 | 467 | icon->img = purple_buddy_icon_data_new(data, len); |
|
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
|
468 | 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
|
469 | g_free(data); |
|
16544
945caa0d6436
Kill some compiler warnings and TODOs of mine.
Richard Laager <rlaager@pidgin.im>
parents:
16539
diff
changeset
|
470 | } |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
471 | |
|
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
|
472 | 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
|
473 | 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
|
474 | |
|
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
|
475 | purple_buddy_icon_update(icon); |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
476 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
477 | if (old_img) |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
478 | g_object_unref(old_img); |
|
15132
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
479 | } |
|
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
480 | |
| 15884 | 481 | PurpleAccount * |
| 482 | purple_buddy_icon_get_account(const PurpleBuddyIcon *icon) | |
| 6846 | 483 | { |
| 484 | g_return_val_if_fail(icon != NULL, NULL); | |
| 485 | ||
| 486 | return icon->account; | |
| 487 | } | |
| 488 | ||
| 489 | const char * | |
| 15884 | 490 | purple_buddy_icon_get_username(const PurpleBuddyIcon *icon) |
| 6846 | 491 | { |
| 492 | g_return_val_if_fail(icon != NULL, NULL); | |
| 493 | ||
| 494 | return icon->username; | |
| 495 | } | |
| 496 | ||
|
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
|
497 | 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
|
498 | 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
|
499 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
500 | 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
|
501 | |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
502 | 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
|
503 | } |
|
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 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
505 | gconstpointer |
| 15884 | 506 | purple_buddy_icon_get_data(const PurpleBuddyIcon *icon, size_t *len) |
| 6846 | 507 | { |
| 508 | g_return_val_if_fail(icon != NULL, NULL); | |
| 509 | ||
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
510 | 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
|
511 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
512 | if (len != NULL) |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
513 | *len = purple_image_get_size(icon->img); |
| 6846 | 514 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
515 | return purple_image_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
|
516 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
517 | |
|
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 | return NULL; |
|
15132
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
519 | } |
|
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
520 | |
|
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
521 | 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
|
522 | purple_buddy_icon_get_extension(const PurpleBuddyIcon *icon) |
|
10953
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
523 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
524 | if (icon->img != NULL) |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
525 | return purple_image_get_extension(icon->img); |
|
10953
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
526 | |
|
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
527 | return NULL; |
|
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
528 | } |
|
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
529 | |
| 6846 | 530 | void |
| 15884 | 531 | 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
|
532 | 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
|
533 | const char *checksum) |
| 6846 | 534 | { |
|
16900
e9f12eb06c5b
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@pidgin.im>
parents:
16863
diff
changeset
|
535 | 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
|
536 | 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
|
537 | |
| 6846 | 538 | g_return_if_fail(account != NULL); |
| 539 | g_return_if_fail(username != NULL); | |
| 540 | ||
|
16900
e9f12eb06c5b
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@pidgin.im>
parents:
16863
diff
changeset
|
541 | 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
|
542 | |
|
e9f12eb06c5b
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@pidgin.im>
parents:
16863
diff
changeset
|
543 | 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
|
544 | icon = g_hash_table_lookup(icon_cache, username); |
|
9305
63a1b462a208
[gaim-migrate @ 10113]
Christian Hammond <chipx86@chipx86.com>
parents:
9285
diff
changeset
|
545 | |
|
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
|
546 | 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
|
547 | 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
|
548 | else if (icon_data && icon_len > 0) |
|
9305
63a1b462a208
[gaim-migrate @ 10113]
Christian Hammond <chipx86@chipx86.com>
parents:
9285
diff
changeset
|
549 | { |
|
20242
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
550 | 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
|
551 | |
|
20242
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
552 | /* purple_buddy_icon_new() calls |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
553 | * purple_buddy_icon_set_data(), which calls |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
554 | * purple_buddy_icon_update(), which has the buddy list |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
555 | * and conversations take references as appropriate. |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
556 | * This function doesn't return icon, so we can't |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
557 | * leave a reference dangling. */ |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
558 | purple_buddy_icon_unref(icon); |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
559 | } |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
560 | else |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
561 | { |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
562 | /* If the buddy list or a conversation was holding a |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
563 | * reference, we'd have found the icon in the cache. |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
564 | * Since we know we're deleting the icon, we only |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
565 | * need a subset of purple_buddy_icon_update(). */ |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
566 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34699
diff
changeset
|
567 | GSList *buddies = purple_blist_find_buddies(account, username); |
|
20242
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
568 | 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
|
569 | { |
|
20242
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
570 | 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
|
571 | |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
572 | unref_filename(purple_blist_node_get_string((PurpleBlistNode *)buddy, "buddy_icon")); |
|
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
573 | purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "buddy_icon"); |
|
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
574 | 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
|
575 | |
|
20242
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
576 | 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
|
577 | } |
|
9305
63a1b462a208
[gaim-migrate @ 10113]
Christian Hammond <chipx86@chipx86.com>
parents:
9285
diff
changeset
|
578 | } |
| 6846 | 579 | } |
| 580 | ||
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
581 | const gchar * |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
582 | purple_buddy_icon_get_full_path(PurpleBuddyIcon *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
|
583 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
584 | const gchar *path; |
|
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
|
585 | |
|
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
|
586 | 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
|
587 | |
|
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 | 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
|
589 | 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
|
590 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
591 | path = purple_image_get_path(icon->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
|
592 | 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
|
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 | 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
|
595 | } |
|
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 | 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
|
597 | } |
|
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 | |
|
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
|
599 | 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
|
600 | 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
|
601 | { |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
602 | return purple_blist_node_get_string((PurpleBlistNode*)buddy, |
|
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
|
603 | "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
|
604 | } |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
605 | |
|
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
|
606 | 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
|
607 | 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
|
608 | { |
|
16532
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
609 | 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
|
610 | |
|
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
|
611 | 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
|
612 | { |
|
16532
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
613 | 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
|
614 | 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
|
615 | 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
|
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 | 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
|
618 | } |
|
16532
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
619 | |
|
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
620 | 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
|
621 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
622 | |
| 15884 | 623 | PurpleBuddyIcon * |
| 624 | purple_buddy_icons_find(PurpleAccount *account, const char *username) | |
| 6846 | 625 | { |
| 626 | 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
|
627 | PurpleBuddyIcon *icon = NULL; |
| 6846 | 628 | |
| 629 | g_return_val_if_fail(account != NULL, NULL); | |
| 630 | g_return_val_if_fail(username != NULL, NULL); | |
| 631 | ||
| 632 | icon_cache = g_hash_table_lookup(account_cache, account); | |
| 633 | ||
|
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
|
634 | 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
|
635 | { |
| 33664 | 636 | /* The icon is not currently cached in memory--try reading from disk */ |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34699
diff
changeset
|
637 | PurpleBuddy *b = purple_blist_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
|
638 | 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
|
639 | 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
|
640 | 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
|
641 | 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
|
642 | size_t len; |
| 9396 | 643 | |
| 644 | if (!b) | |
| 645 | return NULL; | |
| 646 | ||
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
647 | protocol_icon_file = purple_blist_node_get_string((PurpleBlistNode*)b, "buddy_icon"); |
|
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
|
648 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
649 | if (protocol_icon_file == NULL) |
| 9396 | 650 | return NULL; |
| 6846 | 651 | |
|
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
|
652 | 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
|
653 | |
|
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 | 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
|
655 | /* 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
|
656 | * 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
|
657 | * 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
|
658 | 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
|
659 | |
|
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 | 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
|
661 | { |
|
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 | 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
|
663 | 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
|
664 | { |
|
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
|
665 | 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
|
666 | |
|
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
|
667 | 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
|
668 | icon->img = NULL; |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
669 | 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
|
670 | 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
|
671 | } |
|
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
|
672 | else |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
673 | delete_buddy_icon_settings((PurpleBlistNode*)b, "buddy_icon"); |
|
22154
b7ab5a12d97a
Remove spurious braces
Evan Schoenberg <evands@pidgin.im>
parents:
22150
diff
changeset
|
674 | |
|
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
|
675 | 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
|
676 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
677 | |
|
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 | 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
|
679 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
680 | |
|
22161
be6ccc274119
Apparently "nil" is an Objective-C thing
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22158
diff
changeset
|
681 | 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
|
682 | } |
|
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 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
684 | PurpleImage * |
|
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
|
685 | 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
|
686 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
687 | PurpleImage *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
|
688 | 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
|
689 | 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
|
690 | 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
|
691 | 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
|
692 | 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
|
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 | 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
|
695 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
696 | img = g_hash_table_lookup(pointer_icon_cache, account); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
697 | if (img) { |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
698 | g_object_ref(img); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
699 | return 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
|
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 | |
|
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 | 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
|
703 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
704 | if (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
|
705 | 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
|
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 | 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
|
708 | 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
|
709 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
710 | if (read_icon_file(path, &data, &len)) { |
|
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
|
711 | g_free(path); |
|
29234
1d444b1479d7
Fix a crash when setting a buddyicon.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27783
diff
changeset
|
712 | img = purple_buddy_icons_set_account_icon(account, data, len); |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
713 | g_object_ref(img); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
714 | return 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
|
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 | 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
|
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 | 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
|
719 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
720 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
721 | PurpleImage * |
|
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
|
722 | 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
|
723 | 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
|
724 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
725 | PurpleImage *old_img; |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
726 | PurpleImage *img = 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
|
727 | 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
|
728 | |
| 33664 | 729 | if (icon_data != NULL && icon_len > 0) { |
| 730 | img = purple_buddy_icon_data_new(icon_data, icon_len); | |
|
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
|
731 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
732 | |
|
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 | 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
|
734 | 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
|
735 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
736 | const char *filename = image_get_filename(img); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
737 | g_warn_if_fail(filename != 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
|
738 | purple_account_set_string(account, "buddy_icon", filename); |
|
16677
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
739 | 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
|
740 | 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
|
741 | } |
|
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 | 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
|
743 | { |
|
16544
945caa0d6436
Kill some compiler warnings and TODOs of mine.
Richard Laager <rlaager@pidgin.im>
parents:
16539
diff
changeset
|
744 | purple_account_set_string(account, "buddy_icon", NULL); |
|
16677
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
745 | 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
|
746 | } |
|
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 | 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
|
748 | |
|
25745
48b7ebd7fcc7
Fix the crash/leaks in statusbox
Paul Aurich <darkrain42@pidgin.im>
parents:
24569
diff
changeset
|
749 | 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
|
750 | |
|
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
|
751 | 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
|
752 | 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
|
753 | 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
|
754 | g_hash_table_remove(pointer_icon_cache, account); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
755 | |
|
31690
64df30efd8be
In purple_buddy_icons_set_account_icon, call the prpl's set_buddy_icon
Mark Doliner <markdoliner@pidgin.im>
parents:
31590
diff
changeset
|
756 | if (!purple_account_is_disconnected(account)) |
|
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
|
757 | { |
|
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
|
758 | PurpleConnection *gc; |
|
36544
1bf8b6ef5aea
Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents:
36365
diff
changeset
|
759 | PurpleProtocol *protocol; |
|
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
|
760 | |
|
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
|
761 | gc = purple_account_get_connection(account); |
|
36623
caaadef03507
Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents:
36610
diff
changeset
|
762 | protocol = purple_connection_get_protocol(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
|
763 | |
|
36610
3d99b9c0bf90
Refactored account, blist, buddyicon, connection, conversation, presence to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36606
diff
changeset
|
764 | if (protocol) |
| 36719 | 765 | purple_protocol_server_iface_set_buddy_icon(protocol, gc, 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
|
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 | |
|
25745
48b7ebd7fcc7
Fix the crash/leaks in statusbox
Paul Aurich <darkrain42@pidgin.im>
parents:
24569
diff
changeset
|
768 | if (old_img) |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
769 | g_object_unref(old_img); |
|
16674
95bfc8f3775c
Fix assertion when creating a new account.
Daniel Atallah <datallah@pidgin.im>
parents:
16657
diff
changeset
|
770 | 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
|
771 | { |
|
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 | /* 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
|
773 | * 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
|
774 | * 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
|
775 | 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
|
776 | } |
|
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 | 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
|
778 | |
|
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 | 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
|
780 | } |
|
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 | |
|
16677
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
782 | time_t |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
783 | purple_buddy_icons_get_account_icon_timestamp(PurpleAccount *account) |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
784 | { |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
785 | time_t ret; |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
786 | |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
787 | g_return_val_if_fail(account != NULL, 0); |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
788 | |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
789 | ret = purple_account_get_int(account, "buddy_icon_timestamp", 0); |
|
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 | /* This deals with migration cases. */ |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
792 | 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
|
793 | { |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
794 | ret = time(NULL); |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
795 | purple_account_set_int(account, "buddy_icon_timestamp", ret); |
|
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 | |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
798 | return ret; |
|
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 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
801 | gboolean |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
802 | 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
|
803 | { |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
804 | 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
|
805 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
806 | 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
|
807 | } |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
808 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
809 | PurpleImage * |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
810 | purple_buddy_icons_node_find_custom_icon(PurpleBlistNode *node) |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
811 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
812 | char *path; |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
813 | 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
|
814 | guchar *data; |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
815 | PurpleImage *img; |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
816 | 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
|
817 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
818 | 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
|
819 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
820 | img = g_hash_table_lookup(pointer_icon_cache, node); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
821 | if (img) { |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
822 | g_object_ref(img); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
823 | 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
|
824 | } |
|
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 | 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
|
827 | "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
|
828 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
829 | 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
|
830 | 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
|
831 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
832 | 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
|
833 | 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
|
834 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
835 | if (read_icon_file(path, &data, &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
|
836 | g_free(path); |
|
29234
1d444b1479d7
Fix a crash when setting a buddyicon.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27783
diff
changeset
|
837 | img = purple_buddy_icons_node_set_custom_icon(node, data, len); |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
838 | g_object_ref(img); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
839 | 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
|
840 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
841 | 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
|
842 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
843 | 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
|
844 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
845 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
846 | PurpleImage * |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
847 | purple_buddy_icons_node_set_custom_icon(PurpleBlistNode *node, |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
848 | 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
|
849 | { |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
850 | char *old_icon; |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
851 | PurpleImage *old_img; |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
852 | PurpleImage *img = NULL; |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
853 | PurpleBlistUiOps *ops = purple_blist_get_ui_ops(); |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
854 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
855 | 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
|
856 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
857 | if (!PURPLE_IS_CONTACT(node) && |
|
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
858 | !PURPLE_IS_CHAT(node) && |
|
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
859 | !PURPLE_IS_GROUP(node)) { |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
860 | return NULL; |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
861 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
862 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
863 | 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
|
864 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
865 | if (icon_data != NULL && icon_len > 0) { |
| 33664 | 866 | img = purple_buddy_icon_data_new(icon_data, icon_len); |
|
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
|
867 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
868 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
869 | 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
|
870 | "custom_buddy_icon")); |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
871 | if (img && purple_buddy_icons_is_caching()) { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
872 | const char *filename = image_get_filename(img); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
873 | g_warn_if_fail(filename); |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
874 | 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
|
875 | filename); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
876 | ref_filename(filename); |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
877 | } else { |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
878 | 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
|
879 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
880 | 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
|
881 | |
|
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
|
882 | if (img) |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
883 | 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
|
884 | else |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
885 | 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
|
886 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
887 | if (PURPLE_IS_CONTACT(node)) { |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
888 | PurpleBlistNode *child; |
|
24955
77727fac30c6
Finish off the libpurple updates for the hidden blist structs
Gary Kramlich <grim@reaperworld.com>
parents:
24569
diff
changeset
|
889 | 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
|
890 | child; |
|
77727fac30c6
Finish off the libpurple updates for the hidden blist structs
Gary Kramlich <grim@reaperworld.com>
parents:
24569
diff
changeset
|
891 | 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
|
892 | { |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
893 | PurpleBuddy *buddy; |
|
34645
a04c721bebf1
Refactored accounts, blist, cmds and connection to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
894 | PurpleIMConversation *im; |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
895 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
896 | if (!PURPLE_IS_BUDDY(child)) |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
897 | continue; |
|
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 | 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
|
900 | |
|
34645
a04c721bebf1
Refactored accounts, blist, cmds and connection to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
901 | im = purple_conversations_find_im_with_account(purple_buddy_get_name(buddy), purple_buddy_get_account(buddy)); |
|
a04c721bebf1
Refactored accounts, blist, cmds and connection to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
902 | if (im) |
|
a04c721bebf1
Refactored accounts, blist, cmds and connection to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
903 | purple_conversation_update(PURPLE_CONVERSATION(im), PURPLE_CONVERSATION_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
|
904 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
905 | /* 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
|
906 | * 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
|
907 | * icon changes? */ |
| 34730 | 908 | if (ops && ops->update) |
| 909 | ops->update(purple_blist_get_buddy_list(), PURPLE_BLIST_NODE(buddy)); | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
910 | } |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
911 | } else if (PURPLE_IS_CHAT(node)) { |
|
34645
a04c721bebf1
Refactored accounts, blist, cmds and connection to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
912 | PurpleChatConversation *chat = NULL; |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
913 | |
|
34645
a04c721bebf1
Refactored accounts, blist, cmds and connection to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
914 | chat = purple_conversations_find_chat_with_account(purple_chat_get_name((PurpleChat*)node), purple_chat_get_account((PurpleChat*)node)); |
|
a04c721bebf1
Refactored accounts, blist, cmds and connection to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
915 | if (chat) { |
|
a04c721bebf1
Refactored accounts, blist, cmds and connection to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
916 | purple_conversation_update(PURPLE_CONVERSATION(chat), PURPLE_CONVERSATION_UPDATE_ICON); |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
917 | } |
|
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 | } |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
919 | |
| 34730 | 920 | if (ops && ops->update) |
| 921 | ops->update(purple_blist_get_buddy_list(), node); | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
922 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
923 | if (old_img) { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
924 | g_object_unref(old_img); |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
925 | } else if (old_icon) { |
|
16533
91e3e84b05f2
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@pidgin.im>
parents:
16532
diff
changeset
|
926 | /* 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
|
927 | * 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
|
928 | * 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
|
929 | 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
|
930 | } |
|
91e3e84b05f2
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@pidgin.im>
parents:
16532
diff
changeset
|
931 | 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
|
932 | |
|
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 | 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
|
934 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
935 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
936 | PurpleImage * |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
937 | purple_buddy_icons_node_set_custom_icon_from_file(PurpleBlistNode *node, |
|
23285
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
938 | 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
|
939 | { |
|
24273
f5b589130c88
Don't try to read data from a NULL filename in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23285
diff
changeset
|
940 | 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
|
941 | 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
|
942 | |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
943 | 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
|
944 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
945 | if (!PURPLE_IS_CONTACT(node) && |
|
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
946 | !PURPLE_IS_CHAT(node) && |
|
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
947 | !PURPLE_IS_GROUP(node)) { |
|
23285
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
948 | 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
|
949 | } |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
950 | |
|
24273
f5b589130c88
Don't try to read data from a NULL filename in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23285
diff
changeset
|
951 | 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
|
952 | 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
|
953 | 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
|
954 | } |
|
23285
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
955 | } |
|
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 | 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
|
958 | } |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
959 | |
|
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
|
960 | static void |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
961 | delete_buddy_icon_settings(PurpleBlistNode *node, const char *setting_name) |
|
16614
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
962 | { |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
963 | 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
|
964 | |
|
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
|
965 | 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
|
966 | { |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
967 | 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
|
968 | 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
|
969 | } |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
970 | } |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
971 | |
|
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
|
972 | void |
|
16696
450ba3bd5b63
The GNOME coding guidelines recommend prefixing internal symbols with an underscore.
Richard Laager <rlaager@pidgin.im>
parents:
16690
diff
changeset
|
973 | _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
|
974 | { |
|
16567
4d79ee03965d
This is probably needed to compile.
Richard Laager <rlaager@pidgin.im>
parents:
16566
diff
changeset
|
975 | const char *dirname = purple_buddy_icons_get_cache_dir(); |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
976 | GList *cur; |
|
16565
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
977 | |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
978 | 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
|
979 | { |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
980 | PurpleAccount *account = cur->data; |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
981 | 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
|
982 | |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
983 | if (account_icon_file != NULL) |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
984 | { |
|
16568
b26c36d6cf2d
I really shouldn't commit before compiling.
Richard Laager <rlaager@pidgin.im>
parents:
16567
diff
changeset
|
985 | 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
|
986 | 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
|
987 | { |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
988 | 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
|
989 | } else { |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
990 | ref_filename(account_icon_file); |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
991 | } |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
992 | g_free(path); |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
993 | } |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
994 | } |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
995 | } |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
996 | |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
997 | void |
|
16696
450ba3bd5b63
The GNOME coding guidelines recommend prefixing internal symbols with an underscore.
Richard Laager <rlaager@pidgin.im>
parents:
16690
diff
changeset
|
998 | _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
|
999 | { |
|
34864
0e292d8887de
Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents:
34833
diff
changeset
|
1000 | PurpleBlistNode *node = purple_blist_get_root(); |
|
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
|
1001 | 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
|
1002 | |
|
16657
63e53570702c
Whitespace fix from patch in ticket #383
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16632
diff
changeset
|
1003 | 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
|
1004 | { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
1005 | if (PURPLE_IS_BUDDY(node)) |
|
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
|
1006 | { |
|
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 | 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
|
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 | 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
|
1010 | 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
|
1011 | { |
|
31590
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1012 | char *path = g_build_filename(dirname, filename, NULL); |
|
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1013 | if (!g_file_test(path, G_FILE_TEST_EXISTS)) |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1014 | { |
|
31590
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1015 | purple_blist_node_remove_setting(node, |
|
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1016 | "buddy_icon"); |
|
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1017 | purple_blist_node_remove_setting(node, |
|
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1018 | "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
|
1019 | } |
|
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 | else |
|
31590
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1021 | ref_filename(filename); |
|
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1022 | 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
|
1023 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1024 | } |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
1025 | else if (PURPLE_IS_CONTACT(node) || |
|
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
1026 | PURPLE_IS_CHAT(node) || |
|
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
1027 | PURPLE_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
|
1028 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1029 | 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
|
1030 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1031 | 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
|
1032 | 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
|
1033 | { |
|
31590
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1034 | char *path = g_build_filename(dirname, filename, NULL); |
|
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1035 | if (!g_file_test(path, G_FILE_TEST_EXISTS)) |
|
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
|
1036 | { |
|
31590
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1037 | purple_blist_node_remove_setting(node, |
|
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1038 | "custom_buddy_icon"); |
|
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
|
1039 | } |
|
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 | else |
|
31590
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1041 | ref_filename(filename); |
|
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1042 | 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
|
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 | } |
|
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 | 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
|
1046 | } |
| 6846 | 1047 | } |
| 1048 | ||
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1049 | void |
| 15884 | 1050 | purple_buddy_icons_set_caching(gboolean caching) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1051 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1052 | icon_caching = caching; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1053 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1054 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1055 | gboolean |
| 15884 | 1056 | purple_buddy_icons_is_caching(void) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1057 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1058 | return icon_caching; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1059 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1060 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1061 | void |
| 15884 | 1062 | purple_buddy_icons_set_cache_dir(const char *dir) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1063 | { |
|
10811
6b7ac5a9dd35
[gaim-migrate @ 12464]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
1064 | g_return_if_fail(dir != NULL); |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1065 | |
|
13934
c554909e9ff6
[gaim-migrate @ 16342]
Mark Doliner <markdoliner@pidgin.im>
parents:
13555
diff
changeset
|
1066 | g_free(cache_dir); |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1067 | cache_dir = g_strdup(dir); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1068 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1069 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1070 | const char * |
| 15884 | 1071 | purple_buddy_icons_get_cache_dir(void) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1072 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1073 | return cache_dir; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1074 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1075 | |
| 6846 | 1076 | void * |
| 15884 | 1077 | purple_buddy_icons_get_handle() |
| 6846 | 1078 | { |
| 1079 | static int handle; | |
| 1080 | ||
| 1081 | return &handle; | |
| 1082 | } | |
| 1083 | ||
| 1084 | void | |
| 15884 | 1085 | purple_buddy_icons_init() |
| 6846 | 1086 | { |
| 1087 | account_cache = g_hash_table_new_full( | |
| 1088 | g_direct_hash, g_direct_equal, | |
| 1089 | NULL, (GFreeFunc)g_hash_table_destroy); | |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1090 | |
|
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
|
1091 | 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
|
1092 | 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
|
1093 | 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
|
1094 | 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
|
1095 | 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
|
1096 | |
|
22159
9539d60302c9
If the UI sets a cache directory before purple_buddy_icons_init() is called
Evan Schoenberg <evands@pidgin.im>
parents:
22158
diff
changeset
|
1097 | if (!cache_dir) |
| 33664 | 1098 | cache_dir = g_build_filename(purple_user_dir(), "icons", NULL); |
| 6846 | 1099 | } |
| 1100 | ||
| 1101 | void | |
| 15884 | 1102 | purple_buddy_icons_uninit() |
| 6846 | 1103 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1104 | 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
|
1105 | |
| 6846 | 1106 | 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
|
1107 | 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
|
1108 | 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
|
1109 | g_hash_table_destroy(pointer_icon_cache); |
|
26744
ac7a89587cad
Various libpurple uninit memory cleanups.
Nick Hebner <hebnern@gmail.com>
parents:
25888
diff
changeset
|
1110 | 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
|
1111 | |
|
c351bc2db920
Zero freed memory to avoid a crash on re-init.
Ludovico Cavedon <ludovico.cavedon@gmail.com>
parents:
29234
diff
changeset
|
1112 | cache_dir = NULL; |
| 6846 | 1113 | } |
| 10483 | 1114 | |
|
36624
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1115 | GType |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1116 | purple_buddy_icon_get_type(void) |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1117 | { |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1118 | static GType type = 0; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1119 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1120 | if (type == 0) { |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1121 | type = g_boxed_type_register_static("PurpleBuddyIcon", |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1122 | (GBoxedCopyFunc)purple_buddy_icon_ref, |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1123 | (GBoxedFreeFunc)purple_buddy_icon_unref); |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1124 | } |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1125 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1126 | return type; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1127 | } |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1128 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1129 | PurpleBuddyIconSpec * |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1130 | purple_buddy_icon_spec_new(char *format, int min_width, int min_height, |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1131 | int max_width, int max_height, size_t max_filesize, |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1132 | PurpleIconScaleRules scale_rules) |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1133 | { |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1134 | PurpleBuddyIconSpec *icon_spec; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1135 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1136 | icon_spec = g_new0(PurpleBuddyIconSpec, 1); |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1137 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1138 | icon_spec->format = format; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1139 | icon_spec->min_width = min_width; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1140 | icon_spec->min_height = min_height; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1141 | icon_spec->max_width = max_width; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1142 | icon_spec->max_height = max_height; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1143 | icon_spec->max_filesize = max_filesize; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1144 | icon_spec->scale_rules = scale_rules; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1145 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1146 | return icon_spec; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1147 | } |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1148 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1149 | static PurpleBuddyIconSpec * |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1150 | purple_buddy_icon_spec_copy(PurpleBuddyIconSpec *icon_spec) |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1151 | { |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1152 | PurpleBuddyIconSpec *icon_spec_copy; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1153 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1154 | g_return_val_if_fail(icon_spec != NULL, NULL); |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1155 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1156 | icon_spec_copy = g_new0(PurpleBuddyIconSpec, 1); |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1157 | *icon_spec_copy = *icon_spec; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1158 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1159 | return icon_spec_copy; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1160 | } |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1161 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1162 | void purple_buddy_icon_spec_get_scaled_size(PurpleBuddyIconSpec *spec, |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1163 | int *width, int *height) |
| 10483 | 1164 | { |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1165 | int new_width, new_height; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1166 | |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1167 | new_width = *width; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1168 | new_height = *height; |
|
10523
ef52a88a8512
[gaim-migrate @ 11840]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10483
diff
changeset
|
1169 | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1170 | if (*width < spec->min_width) |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1171 | new_width = spec->min_width; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1172 | else if (*width > spec->max_width) |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1173 | new_width = spec->max_width; |
| 10483 | 1174 | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1175 | if (*height < spec->min_height) |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1176 | new_height = spec->min_height; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1177 | else if (*height > spec->max_height) |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1178 | new_height = spec->max_height; |
|
10523
ef52a88a8512
[gaim-migrate @ 11840]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10483
diff
changeset
|
1179 | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1180 | /* preserve aspect ratio */ |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1181 | if ((double)*height * (double)new_width > |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1182 | (double)*width * (double)new_height) { |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1183 | new_width = 0.5 + (double)*width * (double)new_height / (double)*height; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1184 | } else { |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1185 | new_height = 0.5 + (double)*height * (double)new_width / (double)*width; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1186 | } |
|
10523
ef52a88a8512
[gaim-migrate @ 11840]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10483
diff
changeset
|
1187 | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1188 | *width = new_width; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1189 | *height = new_height; |
| 10483 | 1190 | } |
|
34832
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1191 | |
|
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1192 | GType |
|
36624
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1193 | purple_buddy_icon_spec_get_type(void) |
|
34832
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1194 | { |
|
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1195 | static GType type = 0; |
|
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1196 | |
|
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1197 | if (type == 0) { |
|
36624
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1198 | type = g_boxed_type_register_static("PurpleBuddyIconSpec", |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1199 | (GBoxedCopyFunc)purple_buddy_icon_spec_copy, |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1200 | (GBoxedFreeFunc)g_free); |
|
34832
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1201 | } |
|
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1202 | |
|
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1203 | return type; |
|
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1204 | } |