Sat, 13 Apr 2024 18:05:52 -0500
Remove PurpleConversationUiOps
Nothing was using this anymore as we've been slowing migrating away from them.
Testing Done:
Called in the turtles.
Reviewed at https://reviews.imfreedom.org/r/3104/
|
42594
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42434
diff
changeset
|
1 | /* |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42434
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42434
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
| 6846 | 4 | * |
| 15884 | 5 | * Purple is the legal property of its developers, whose names are too numerous |
|
42594
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42434
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 8046 | 7 | * source distribution. |
| 6846 | 8 | * |
|
42594
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42434
diff
changeset
|
9 | * This library is free software; you can redistribute it and/or modify it |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42434
diff
changeset
|
10 | * under the terms of the GNU General Public License as published by the Free |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42434
diff
changeset
|
11 | * Software Foundation; either version 2 of the License, or (at your option) |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42434
diff
changeset
|
12 | * any later version. |
| 6846 | 13 | * |
|
42594
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42434
diff
changeset
|
14 | * This library is distributed in the hope that it will be useful, but WITHOUT |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42434
diff
changeset
|
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42434
diff
changeset
|
16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42434
diff
changeset
|
17 | * more details. |
| 6846 | 18 | * |
|
42594
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42434
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License along with |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42434
diff
changeset
|
20 | * this library; if not, see <https://www.gnu.org/licenses/>. |
| 6846 | 21 | */ |
|
24569
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 "buddyicon.h" |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
24 | #include "debug.h" |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
25 | #include "image.h" |
|
41181
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
26 | #include "purpleaccountmanager.h" |
|
42706
6039c89f2f5c
Remove PurpleConversationUiOps
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
27 | #include "purplechatconversation.h" |
|
40853
d3518ff99fa7
rename conversation.[ch] to purpleconversation.[ch] and split PurpleConversationUiOps out to its own file to avoid circular include issues.
Gary Kramlich <grim@reaperworld.com>
parents:
40813
diff
changeset
|
28 | #include "purpleconversation.h" |
|
40992
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
29 | #include "purpleconversationmanager.h" |
|
41237
5098e0dd3a09
Move the path based functions from util.c to their own file.
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
30 | #include "purplepath.h" |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
39913
diff
changeset
|
31 | #include "purpleprivate.h" |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
32 | #include "purpleprotocolserver.h" |
| 6846 | 33 | |
|
42434
622b4989d073
Fix some Windows build header issues
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42172
diff
changeset
|
34 | #ifdef _WIN32 |
|
622b4989d073
Fix some Windows build header issues
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42172
diff
changeset
|
35 | # include "win32/libc_interface.h" |
|
622b4989d073
Fix some Windows build header issues
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42172
diff
changeset
|
36 | #endif |
|
622b4989d073
Fix some Windows build header issues
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42172
diff
changeset
|
37 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
38 | /* NOTE: Instances of this struct are allocated without zeroing the memory, so |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
39 | * NOTE: be sure to update purple_buddy_icon_new() if you add members. */ |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
40 | struct _PurpleBuddyIcon |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
41 | { |
|
35458
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
42 | PurpleAccount *account; /* The account the user is on. */ |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
43 | 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
|
44 | the icon data. */ |
|
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
45 | 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
|
46 | char *checksum; /* The protocol checksum. */ |
|
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
47 | unsigned int ref_count; /* The buddy icon reference count. */ |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
48 | }; |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
49 | |
|
35458
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
50 | /* |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
51 | * This is the big grand daddy hash table that contains references to |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
52 | * everybody's buddy icons. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
53 | * |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
54 | * Key is a PurpleAccount. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
55 | * Value is another hash table, usually referred to as "icon_cache." |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
56 | * For this inner hash table: |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
57 | * Key is the username of the buddy whose icon is being stored. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
58 | * Value is the PurpleBuddyIcon for this buddy. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
59 | */ |
| 6846 | 60 | static GHashTable *account_cache = NULL; |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
61 | |
|
35458
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
62 | /* |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
63 | * This hash table contains a bunch of PurpleImages that are |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
64 | * shared across all accounts. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
65 | * |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
66 | * 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
|
67 | * purple_image_generate_filename(). So it is the base16 encoded |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
68 | * sha-1 hash plus an appropriate file extension. For example: |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
69 | * "0f4972d17d1e70e751c43c90c948e72efbff9796.gif" |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
70 | * |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
71 | * 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
|
72 | * 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
|
73 | * 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
|
74 | * used by offline accounts or some such). |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
75 | */ |
|
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
|
76 | static GHashTable *icon_data_cache = NULL; |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
77 | |
|
35458
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
78 | /* |
| 33664 | 79 | * This hash table contains reference counts for how many times each |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
80 | * icon in the ~/.purple/icons/ directory is being used. It's pretty |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
81 | * crazy. It maintains the reference count across sessions, too, so |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
82 | * if you exit Pidgin then this hash table is reconstructed the next |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
83 | * time Pidgin starts. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
84 | * |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
85 | * 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
|
86 | * purple_image_generate_filename(). So it is the base16 encoded |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
87 | * sha-1 hash plus an appropriate file extension. For example: |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
88 | * "0f4972d17d1e70e751c43c90c948e72efbff9796.gif" |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
89 | * |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
90 | * 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
|
91 | * 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
|
92 | * 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
|
93 | * will be six. When this reference count reaches 0 the icon will |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
94 | * be deleted from disk. |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
95 | */ |
|
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
|
96 | 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
|
97 | |
|
35458
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
98 | /* |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
99 | * This hash table is used for both custom buddy icons on PurpleBlistNodes and |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
100 | * account icons. |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
101 | */ |
|
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
|
102 | 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
|
103 | |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
104 | static char *cache_dir = NULL; |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
105 | |
|
35458
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
106 | /* "Should icons be cached to disk?" */ |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
107 | static gboolean icon_caching = TRUE; |
| 6846 | 108 | |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
109 | static void delete_buddy_icon_settings(PurpleBlistNode *node, const char *setting_name); |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
110 | |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
111 | /* |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
112 | * Begin functions for dealing with the on-disk icon cache |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
113 | */ |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
114 | |
|
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
|
115 | 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
|
116 | 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
|
117 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
118 | 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
|
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 | 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
|
121 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
122 | 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
|
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 | 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
|
125 | 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
|
126 | } |
|
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 | |
|
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 | 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
|
129 | 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
|
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 | 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
|
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 | 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
|
134 | 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
|
135 | |
|
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 | 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
|
137 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
138 | if (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 | 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
|
141 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
142 | 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
|
143 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
144 | 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
|
145 | 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
|
146 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
147 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
148 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
149 | static const gchar * |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
150 | 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
|
151 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
152 | 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
|
153 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
154 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
155 | static void |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
156 | purple_buddy_icon_data_cache(PurpleImage *img) |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
157 | { |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
158 | const gchar *dirname, *filename; |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
159 | gchar *path; |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
160 | |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
161 | 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
|
162 | |
|
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 | 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
|
164 | 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
|
165 | |
| 33664 | 166 | dirname = purple_buddy_icons_get_cache_dir(); |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
167 | filename = image_get_filename(img); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
168 | 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
|
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 | 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
|
171 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
172 | 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
|
173 | |
|
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 | 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
|
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 | purple_debug_error("buddyicon", |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
177 | "unable to create directory %s: %s", |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
178 | dirname, g_strerror(errno)); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
179 | 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
|
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 | |
|
39461
a4ae05d3be93
Fix several g_build_filename leaks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
183 | path = g_build_filename(dirname, filename, NULL); |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
184 | if (!purple_image_save(img, path)) |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
185 | purple_debug_error("buddyicon", "failed to save icon %s", path); |
|
38734
bde01a73937d
Do not rewrite custom buddy icons already in the cache (#17259)
David Woodhouse <dwmw@amazon.co.uk>
parents:
38213
diff
changeset
|
186 | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
187 | 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
|
188 | } |
|
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 | 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
|
191 | 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
|
192 | { |
|
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 | 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
|
194 | 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
|
195 | |
|
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 | 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
|
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 | /* 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
|
199 | * 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
|
200 | 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
|
201 | 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
|
202 | |
| 33664 | 203 | 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
|
204 | 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
|
205 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
206 | 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
|
207 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
208 | 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
|
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 | 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
|
211 | 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
|
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 | 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
|
214 | { |
|
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
|
215 | 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
|
216 | } |
|
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
|
217 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
218 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
219 | 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
|
220 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
221 | |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
222 | /* |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
223 | * End functions for dealing with the on-disk icon cache |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
224 | */ |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
225 | |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
226 | /* |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
227 | * Begin functions for dealing with the in-memory icon cache |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
228 | */ |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
229 | |
|
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
|
230 | static gboolean |
|
41960
c8a4853205e3
Bump C standard to C99 for libpurple files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41840
diff
changeset
|
231 | value_equals(G_GNUC_UNUSED gpointer key, gpointer value, gpointer user_data) |
|
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
|
232 | { |
|
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
|
233 | 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
|
234 | } |
|
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
|
235 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
236 | static void |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
237 | 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
|
238 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
239 | PurpleImage *img; |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
240 | 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
|
241 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
242 | img = g_hash_table_lookup(icon_data_cache, filename); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
243 | purple_buddy_icon_data_uncache_file(filename); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
244 | 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
|
245 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
246 | /* 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
|
247 | * this is probably good enough. */ |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
248 | 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
|
249 | |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
250 | 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
|
251 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
252 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
253 | static PurpleImage * |
| 33664 | 254 | 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
|
255 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
256 | PurpleImage *newimg, *oldimg; |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
257 | 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
|
258 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
259 | g_return_val_if_fail(icon_data != NULL, NULL); |
| 33664 | 260 | 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
|
261 | |
|
41313
c110f79423b3
Fix leak of buddy icon data
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41237
diff
changeset
|
262 | newimg = purple_image_new_take_data(icon_data, icon_len); |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
263 | 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
|
264 | |
|
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
|
265 | /* 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
|
266 | * 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
|
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 | 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
|
269 | 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
|
270 | 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
|
271 | 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
|
272 | 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
|
273 | 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
|
274 | return oldimg; |
|
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
|
275 | } |
|
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
|
276 | |
|
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
|
277 | /* 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
|
278 | 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
|
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 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
281 | 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
|
282 | 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
|
283 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
284 | 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
|
285 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
286 | 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
|
287 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
288 | |
|
22769
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
289 | /* |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
290 | * End functions for dealing with the in-memory icon cache |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
291 | */ |
|
fa73d52f4f67
Documentation changes
Mark Doliner <markdoliner@pidgin.im>
parents:
22763
diff
changeset
|
292 | |
| 15884 | 293 | static PurpleBuddyIcon * |
| 294 | purple_buddy_icon_create(PurpleAccount *account, const char *username) | |
| 9396 | 295 | { |
| 15884 | 296 | PurpleBuddyIcon *icon; |
| 9396 | 297 | GHashTable *icon_cache; |
| 298 | ||
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
299 | /* 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
|
300 | * 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
|
301 | icon = g_slice_new(PurpleBuddyIcon); |
| 9396 | 302 | |
|
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
|
303 | 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
|
304 | 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
|
305 | icon->checksum = NULL; |
|
16924
a061b2ff4cf7
Fix a reference counting bug.
Richard Laager <rlaager@pidgin.im>
parents:
16903
diff
changeset
|
306 | icon->ref_count = 1; |
| 9396 | 307 | |
| 308 | icon_cache = g_hash_table_lookup(account_cache, account); | |
| 309 | ||
| 310 | if (icon_cache == NULL) | |
| 311 | { | |
| 312 | icon_cache = g_hash_table_new(g_str_hash, g_str_equal); | |
| 313 | ||
| 314 | g_hash_table_insert(account_cache, account, icon_cache); | |
| 315 | } | |
| 316 | ||
| 317 | 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
|
318 | (char *)purple_buddy_icon_get_username(icon), icon); |
| 9396 | 319 | return icon; |
| 320 | } | |
| 321 | ||
| 15884 | 322 | PurpleBuddyIcon * |
| 323 | 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
|
324 | 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
|
325 | const char *checksum) |
| 6846 | 326 | { |
| 15884 | 327 | PurpleBuddyIcon *icon; |
| 6846 | 328 | |
| 329 | g_return_val_if_fail(account != NULL, NULL); | |
| 330 | 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
|
331 | 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
|
332 | g_return_val_if_fail(icon_len > 0, NULL); |
| 6846 | 333 | |
|
16438
64e892ac6180
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
334 | /* 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
|
335 | * sure to update it as well when members are added. */ |
| 15884 | 336 | icon = purple_buddy_icons_find(account, username); |
| 6846 | 337 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
338 | /* purple_buddy_icon_create() sets account & username */ |
| 6846 | 339 | if (icon == NULL) |
| 15884 | 340 | icon = purple_buddy_icon_create(account, username); |
| 6846 | 341 | |
|
16438
64e892ac6180
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
342 | /* 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
|
343 | * 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
|
344 | 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
|
345 | 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
|
346 | |
| 6846 | 347 | return icon; |
| 348 | } | |
| 349 | ||
| 15884 | 350 | PurpleBuddyIcon * |
| 351 | purple_buddy_icon_ref(PurpleBuddyIcon *icon) | |
| 6846 | 352 | { |
| 353 | g_return_val_if_fail(icon != NULL, NULL); | |
| 354 | ||
| 355 | icon->ref_count++; | |
| 356 | ||
| 357 | return icon; | |
| 358 | } | |
| 359 | ||
|
33665
55fcd8716546
Change purple_buddy_icon_unref to not return anything.
Mark Doliner <mark@kingant.net>
parents:
33664
diff
changeset
|
360 | void |
| 15884 | 361 | purple_buddy_icon_unref(PurpleBuddyIcon *icon) |
| 6846 | 362 | { |
|
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
|
363 | if (icon == NULL) |
|
33665
55fcd8716546
Change purple_buddy_icon_unref to not return anything.
Mark Doliner <mark@kingant.net>
parents:
33664
diff
changeset
|
364 | 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
|
365 | |
|
33665
55fcd8716546
Change purple_buddy_icon_unref to not return anything.
Mark Doliner <mark@kingant.net>
parents:
33664
diff
changeset
|
366 | g_return_if_fail(icon->ref_count > 0); |
| 6846 | 367 | |
| 368 | icon->ref_count--; | |
| 369 | ||
| 370 | if (icon->ref_count == 0) | |
| 371 | { | |
|
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
|
372 | 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
|
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 | 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
|
375 | 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
|
376 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
377 | 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
|
378 | g_free(icon->checksum); |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
379 | 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
|
380 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
381 | g_slice_free(PurpleBuddyIcon, icon); |
| 6846 | 382 | } |
| 383 | } | |
| 384 | ||
| 385 | void | |
| 15884 | 386 | purple_buddy_icon_update(PurpleBuddyIcon *icon) |
| 6846 | 387 | { |
| 15884 | 388 | PurpleAccount *account; |
| 6846 | 389 | 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
|
390 | 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
|
391 | GSList *buddies; |
| 6846 | 392 | |
| 393 | g_return_if_fail(icon != NULL); | |
| 394 | ||
| 15884 | 395 | account = purple_buddy_icon_get_account(icon); |
| 396 | username = purple_buddy_icon_get_username(icon); | |
| 6846 | 397 | |
|
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
|
398 | /* 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
|
399 | * 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
|
400 | * 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
|
401 | * 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
|
402 | * 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
|
403 | 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
|
404 | |
|
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
|
405 | /* Ensure that icon remains valid throughout */ |
|
33769
96f89e35d24d
Fix various "Dereference before null check" issues
Daniel Atallah <datallah@pidgin.im>
parents:
29296
diff
changeset
|
406 | 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
|
407 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34699
diff
changeset
|
408 | 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
|
409 | while (buddies != NULL) |
| 6846 | 410 | { |
|
16863
b98303c15033
Change a few functions to free a linked list while iterating through
Mark Doliner <markdoliner@pidgin.im>
parents:
16775
diff
changeset
|
411 | 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
|
412 | char *old_icon; |
| 6846 | 413 | |
|
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
|
414 | purple_buddy_set_icon(buddy, icon_to_set); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
415 | old_icon = g_strdup(purple_blist_node_get_string((PurpleBlistNode *)buddy, |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
416 | "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
|
417 | 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
|
418 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
419 | const char *filename = image_get_filename(icon->img); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
420 | g_warn_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
|
421 | purple_blist_node_set_string((PurpleBlistNode *)buddy, |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
422 | "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
|
423 | 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
|
424 | |
|
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 | 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
|
426 | { |
|
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 | purple_blist_node_set_string((PurpleBlistNode *)buddy, |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
428 | "icon_checksum", |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
429 | 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 | } |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
431 | 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
|
432 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
433 | purple_blist_node_remove_setting((PurpleBlistNode *)buddy, |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
434 | "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
|
435 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
436 | 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
|
437 | } |
|
17033
27d9faa34ad1
Patch from ticket #819 from vampire
Richard Laager <rlaager@pidgin.im>
parents:
16924
diff
changeset
|
438 | 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
|
439 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
440 | purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "buddy_icon"); |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
441 | 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
|
442 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
443 | 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
|
444 | 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
|
445 | |
|
b98303c15033
Change a few functions to free a linked list while iterating through
Mark Doliner <markdoliner@pidgin.im>
parents:
16775
diff
changeset
|
446 | buddies = g_slist_delete_link(buddies, buddies); |
| 6846 | 447 | } |
| 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 | |
|
40810
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
481 | gboolean |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
482 | purple_buddy_icon_save_to_filename(PurpleBuddyIcon *icon, |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
483 | const gchar *filename, GError **error) |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
484 | { |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
485 | gconstpointer data; |
|
40889
00c77e22fb64
Fix some issues scanbuild found
Gary Kramlich <grim@reaperworld.com>
parents:
40885
diff
changeset
|
486 | size_t len = 0; |
|
40810
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
487 | |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
488 | data = purple_buddy_icon_get_data(icon, &len); |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
489 | |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
490 | return g_file_set_contents(filename, data, len, error); |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
491 | } |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
492 | |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
493 | |
| 15884 | 494 | PurpleAccount * |
| 495 | purple_buddy_icon_get_account(const PurpleBuddyIcon *icon) | |
| 6846 | 496 | { |
| 497 | g_return_val_if_fail(icon != NULL, NULL); | |
| 498 | ||
| 499 | return icon->account; | |
| 500 | } | |
| 501 | ||
| 502 | const char * | |
| 15884 | 503 | purple_buddy_icon_get_username(const PurpleBuddyIcon *icon) |
| 6846 | 504 | { |
| 505 | g_return_val_if_fail(icon != NULL, NULL); | |
| 506 | ||
| 507 | return icon->username; | |
| 508 | } | |
| 509 | ||
|
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
|
510 | 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
|
511 | 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
|
512 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
513 | 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
|
514 | |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
515 | 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
|
516 | } |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
517 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
518 | gconstpointer |
| 15884 | 519 | purple_buddy_icon_get_data(const PurpleBuddyIcon *icon, size_t *len) |
| 6846 | 520 | { |
| 521 | g_return_val_if_fail(icon != NULL, NULL); | |
| 522 | ||
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
523 | 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
|
524 | { |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
525 | if (len != NULL) |
|
38298
f0a8f63f9312
rename purple_image_get_size to purple_image_get_data_size and deal with the fallout
Gary Kramlich <grim@reaperworld.com>
parents:
37406
diff
changeset
|
526 | *len = purple_image_get_data_size(icon->img); |
| 6846 | 527 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
528 | 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
|
529 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
530 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
531 | return NULL; |
|
15132
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
532 | } |
|
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
533 | |
|
40810
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
534 | GInputStream * |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
535 | purple_buddy_icon_get_stream(PurpleBuddyIcon *icon) { |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
536 | gconstpointer data = NULL; |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
537 | size_t len = 0; |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
538 | |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
539 | g_return_val_if_fail(icon != NULL, NULL); |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
540 | |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
541 | data = purple_buddy_icon_get_data(icon, &len); |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
542 | |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
543 | return g_memory_input_stream_new_from_data(data, (gssize)len, NULL); |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
544 | } |
|
28d50eece92d
Create a PidginAvatar widget.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
545 | |
|
15132
672c39839af1
[gaim-migrate @ 17854]
Mark Huetsch <markhuetsch@users.sourceforge.net>
parents:
15117
diff
changeset
|
546 | 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
|
547 | purple_buddy_icon_get_extension(const PurpleBuddyIcon *icon) |
|
10953
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
548 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
549 | if (icon->img != NULL) |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
550 | return purple_image_get_extension(icon->img); |
|
10953
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
551 | |
|
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
552 | return NULL; |
|
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
553 | } |
|
e5987ea70985
[gaim-migrate @ 12753]
Richard Laager <rlaager@pidgin.im>
parents:
10934
diff
changeset
|
554 | |
| 6846 | 555 | void |
| 15884 | 556 | 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
|
557 | 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
|
558 | const char *checksum) |
| 6846 | 559 | { |
|
16900
e9f12eb06c5b
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@pidgin.im>
parents:
16863
diff
changeset
|
560 | 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
|
561 | 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
|
562 | |
| 6846 | 563 | g_return_if_fail(account != NULL); |
| 564 | g_return_if_fail(username != NULL); | |
| 565 | ||
|
16900
e9f12eb06c5b
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@pidgin.im>
parents:
16863
diff
changeset
|
566 | 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
|
567 | |
|
e9f12eb06c5b
Rework purple_buddy_icons_find() to return a reference for the caller, which
Richard Laager <rlaager@pidgin.im>
parents:
16863
diff
changeset
|
568 | 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
|
569 | icon = g_hash_table_lookup(icon_cache, username); |
|
9305
63a1b462a208
[gaim-migrate @ 10113]
Christian Hammond <chipx86@chipx86.com>
parents:
9285
diff
changeset
|
570 | |
|
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
|
571 | 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
|
572 | 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
|
573 | else if (icon_data && icon_len > 0) |
|
9305
63a1b462a208
[gaim-migrate @ 10113]
Christian Hammond <chipx86@chipx86.com>
parents:
9285
diff
changeset
|
574 | { |
|
20242
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
575 | 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
|
576 | |
|
20242
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
577 | /* purple_buddy_icon_new() calls |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
578 | * purple_buddy_icon_set_data(), which calls |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
579 | * purple_buddy_icon_update(), which has the buddy list |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
580 | * and conversations take references as appropriate. |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
581 | * This function doesn't return icon, so we can't |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
582 | * leave a reference dangling. */ |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
583 | purple_buddy_icon_unref(icon); |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
584 | } |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
585 | else |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
586 | { |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
587 | /* If the buddy list or a conversation was holding a |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
588 | * reference, we'd have found the icon in the cache. |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
589 | * Since we know we're deleting the icon, we only |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
590 | * need a subset of purple_buddy_icon_update(). */ |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
591 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34699
diff
changeset
|
592 | GSList *buddies = purple_blist_find_buddies(account, username); |
|
20242
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
593 | 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
|
594 | { |
|
20242
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
595 | 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
|
596 | |
|
20242
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
597 | unref_filename(purple_blist_node_get_string((PurpleBlistNode *)buddy, "buddy_icon")); |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
598 | purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "buddy_icon"); |
|
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
599 | 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
|
600 | |
|
20242
a1310a256a1a
applied changes from 3ae1e4b3dac8092886b4b8ab961d8d505433b4c4
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
601 | 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
|
602 | } |
|
9305
63a1b462a208
[gaim-migrate @ 10113]
Christian Hammond <chipx86@chipx86.com>
parents:
9285
diff
changeset
|
603 | } |
| 6846 | 604 | } |
| 605 | ||
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
606 | const gchar * |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
607 | 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
|
608 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
609 | 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
|
610 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
611 | 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
|
612 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
613 | 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
|
614 | 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
|
615 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
616 | 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
|
617 | 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
|
618 | { |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
619 | 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
|
620 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
621 | 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
|
622 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
623 | |
|
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
|
624 | 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
|
625 | 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
|
626 | { |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
627 | return purple_blist_node_get_string((PurpleBlistNode*)buddy, |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
628 | "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
|
629 | } |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16533
diff
changeset
|
630 | |
|
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
|
631 | 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
|
632 | 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
|
633 | { |
|
16532
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
634 | 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
|
635 | |
|
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
|
636 | 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
|
637 | { |
|
16532
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
638 | 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
|
639 | 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
|
640 | 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
|
641 | |
|
16532
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
642 | 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
|
643 | } |
|
16532
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
644 | |
|
070f046b1316
Switch to using g_file_get_contents() instead of our own code.
Richard Laager <rlaager@pidgin.im>
parents:
16531
diff
changeset
|
645 | 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
|
646 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
647 | |
| 15884 | 648 | PurpleBuddyIcon * |
| 649 | purple_buddy_icons_find(PurpleAccount *account, const char *username) | |
| 6846 | 650 | { |
| 651 | 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
|
652 | PurpleBuddyIcon *icon = NULL; |
| 6846 | 653 | |
| 654 | g_return_val_if_fail(account != NULL, NULL); | |
| 655 | g_return_val_if_fail(username != NULL, NULL); | |
| 656 | ||
| 657 | icon_cache = g_hash_table_lookup(account_cache, account); | |
| 658 | ||
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
659 | 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
|
660 | { |
| 33664 | 661 | /* 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
|
662 | 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
|
663 | 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
|
664 | 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
|
665 | gboolean caching; |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39678
diff
changeset
|
666 | gchar *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
|
667 | 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
|
668 | size_t len; |
| 9396 | 669 | |
| 670 | if (!b) | |
| 671 | return NULL; | |
| 672 | ||
|
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
|
673 | protocol_icon_file = purple_blist_node_get_string((PurpleBlistNode*)b, "buddy_icon"); |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
674 | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
675 | if (protocol_icon_file == NULL) |
| 9396 | 676 | return NULL; |
| 6846 | 677 | |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
678 | 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
|
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 | 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
|
681 | /* 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
|
682 | * 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
|
683 | * 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
|
684 | 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
|
685 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39678
diff
changeset
|
686 | path = g_build_filename(dirname, protocol_icon_file, NULL); |
|
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39678
diff
changeset
|
687 | if (read_icon_file(path, &data, &len)) { |
|
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39678
diff
changeset
|
688 | const char *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
|
689 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39678
diff
changeset
|
690 | icon = purple_buddy_icon_create(account, username); |
|
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39678
diff
changeset
|
691 | icon->img = NULL; |
|
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39678
diff
changeset
|
692 | checksum = purple_blist_node_get_string((PurpleBlistNode *)b, |
|
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39678
diff
changeset
|
693 | "icon_checksum"); |
|
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39678
diff
changeset
|
694 | purple_buddy_icon_set_data(icon, data, len, checksum); |
|
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39678
diff
changeset
|
695 | } else { |
|
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39678
diff
changeset
|
696 | delete_buddy_icon_settings((PurpleBlistNode *)b, "buddy_icon"); |
|
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39678
diff
changeset
|
697 | } |
|
22154
b7ab5a12d97a
Remove spurious braces
Evan Schoenberg <evands@pidgin.im>
parents:
22150
diff
changeset
|
698 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39678
diff
changeset
|
699 | 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
|
700 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
701 | 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
|
702 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
703 | |
|
22161
be6ccc274119
Apparently "nil" is an Objective-C thing
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22158
diff
changeset
|
704 | 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
|
705 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
706 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
707 | 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
|
708 | 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
|
709 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
710 | 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
|
711 | 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
|
712 | 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
|
713 | 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
|
714 | 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
|
715 | 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
|
716 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
717 | 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
|
718 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
719 | img = g_hash_table_lookup(pointer_icon_cache, account); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
720 | if (img) { |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
721 | g_object_ref(img); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
722 | 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
|
723 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
724 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
725 | 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
|
726 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
727 | 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
|
728 | 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
|
729 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
730 | 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
|
731 | 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
|
732 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
733 | 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
|
734 | g_free(path); |
|
29234
1d444b1479d7
Fix a crash when setting a buddyicon.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27783
diff
changeset
|
735 | 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
|
736 | g_object_ref(img); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
737 | 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
|
738 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
739 | 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
|
740 | |
|
c7e61e2917c9
Updates for the account buddy icon 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 | 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
|
742 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
743 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
744 | 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
|
745 | 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
|
746 | 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
|
747 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
748 | PurpleImage *old_img; |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
749 | 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
|
750 | 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
|
751 | |
| 33664 | 752 | if (icon_data != NULL && icon_len > 0) { |
| 753 | 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
|
754 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
755 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
756 | 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
|
757 | 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
|
758 | { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
759 | const char *filename = image_get_filename(img); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
760 | 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
|
761 | purple_account_set_string(account, "buddy_icon", filename); |
|
16677
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
762 | 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
|
763 | 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
|
764 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
765 | 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
|
766 | { |
|
16544
945caa0d6436
Kill some compiler warnings and TODOs of mine.
Richard Laager <rlaager@pidgin.im>
parents:
16539
diff
changeset
|
767 | purple_account_set_string(account, "buddy_icon", NULL); |
|
16677
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
768 | 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
|
769 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
770 | 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
|
771 | |
|
25745
48b7ebd7fcc7
Fix the crash/leaks in statusbox
Paul Aurich <darkrain42@pidgin.im>
parents:
24569
diff
changeset
|
772 | 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
|
773 | |
|
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
|
774 | 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
|
775 | 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
|
776 | 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
|
777 | g_hash_table_remove(pointer_icon_cache, account); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25859
diff
changeset
|
778 | |
|
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
|
779 | 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
|
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 | PurpleConnection *gc; |
|
36544
1bf8b6ef5aea
Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents:
36365
diff
changeset
|
782 | 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
|
783 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
784 | 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
|
785 | 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
|
786 | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
787 | if(PURPLE_IS_PROTOCOL_SERVER(protocol)) { |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
788 | purple_protocol_server_set_buddy_icon(PURPLE_PROTOCOL_SERVER(protocol), |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
789 | gc, img); |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
790 | } |
|
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
|
791 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
792 | |
|
25745
48b7ebd7fcc7
Fix the crash/leaks in statusbox
Paul Aurich <darkrain42@pidgin.im>
parents:
24569
diff
changeset
|
793 | if (old_img) |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
794 | g_object_unref(old_img); |
|
16674
95bfc8f3775c
Fix assertion when creating a new account.
Daniel Atallah <datallah@pidgin.im>
parents:
16657
diff
changeset
|
795 | 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
|
796 | { |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
797 | /* 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
|
798 | * 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
|
799 | * 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
|
800 | 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
|
801 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
802 | 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
|
803 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
804 | 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
|
805 | } |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
806 | |
|
16677
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
807 | time_t |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
808 | purple_buddy_icons_get_account_icon_timestamp(PurpleAccount *account) |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
809 | { |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
810 | time_t ret; |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
811 | |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
812 | g_return_val_if_fail(account != NULL, 0); |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
813 | |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
814 | ret = purple_account_get_int(account, "buddy_icon_timestamp", 0); |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
815 | |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
816 | /* This deals with migration cases. */ |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
817 | 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
|
818 | { |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
819 | ret = time(NULL); |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
820 | purple_account_set_int(account, "buddy_icon_timestamp", ret); |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
821 | } |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
822 | |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
823 | return ret; |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
824 | } |
|
7cd57586cdbf
The OSCAR timestamp stuff.
Richard Laager <rlaager@pidgin.im>
parents:
16669
diff
changeset
|
825 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
826 | gboolean |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
827 | 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
|
828 | { |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
829 | 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
|
830 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
831 | 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
|
832 | } |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
833 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
834 | PurpleImage * |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
835 | purple_buddy_icons_node_find_custom_icon(PurpleBlistNode *node) |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
836 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
837 | char *path; |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
838 | 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
|
839 | guchar *data; |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
840 | PurpleImage *img; |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
841 | 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
|
842 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
843 | 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
|
844 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
845 | img = g_hash_table_lookup(pointer_icon_cache, node); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
846 | if (img) { |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
847 | g_object_ref(img); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
848 | 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
|
849 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
850 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
851 | 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
|
852 | "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
|
853 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
854 | 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
|
855 | 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
|
856 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
857 | 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
|
858 | 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
|
859 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
860 | 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
|
861 | g_free(path); |
|
29234
1d444b1479d7
Fix a crash when setting a buddyicon.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27783
diff
changeset
|
862 | 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
|
863 | g_object_ref(img); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
864 | 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
|
865 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
866 | 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
|
867 | |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
868 | 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
|
869 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
870 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
871 | PurpleImage * |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
872 | purple_buddy_icons_node_set_custom_icon(PurpleBlistNode *node, |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
873 | 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
|
874 | { |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
875 | char *old_icon; |
|
40992
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
876 | PurpleConversationManager *manager = NULL; |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
877 | PurpleImage *old_img; |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
878 | PurpleImage *img = NULL; |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
879 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
880 | 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
|
881 | |
|
41733
a9085b52de8b
Rename PurpleContact to PurpleMetaContact.
Gary Kramlich <grim@reaperworld.com>
parents:
41685
diff
changeset
|
882 | if (!PURPLE_IS_META_CONTACT(node) && |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
883 | !PURPLE_IS_CHAT(node) && |
|
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
884 | !PURPLE_IS_GROUP(node)) { |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
885 | return NULL; |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
886 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
887 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
888 | 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
|
889 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
890 | if (icon_data != NULL && icon_len > 0) { |
| 33664 | 891 | 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
|
892 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
893 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
894 | 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
|
895 | "custom_buddy_icon")); |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
896 | if (img && purple_buddy_icons_is_caching()) { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
897 | const char *filename = image_get_filename(img); |
|
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
898 | 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
|
899 | 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
|
900 | filename); |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
901 | ref_filename(filename); |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
902 | } else { |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
903 | 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
|
904 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
905 | 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
|
906 | |
|
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
|
907 | if (img) |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
908 | 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
|
909 | else |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
910 | 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
|
911 | |
|
40992
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
912 | manager = purple_conversation_manager_get_default(); |
|
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
913 | |
|
41733
a9085b52de8b
Rename PurpleContact to PurpleMetaContact.
Gary Kramlich <grim@reaperworld.com>
parents:
41685
diff
changeset
|
914 | if (PURPLE_IS_META_CONTACT(node)) { |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
915 | PurpleBlistNode *child; |
|
24955
77727fac30c6
Finish off the libpurple updates for the hidden blist structs
Gary Kramlich <grim@reaperworld.com>
parents:
24569
diff
changeset
|
916 | 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
|
917 | child; |
|
77727fac30c6
Finish off the libpurple updates for the hidden blist structs
Gary Kramlich <grim@reaperworld.com>
parents:
24569
diff
changeset
|
918 | 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
|
919 | { |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
920 | PurpleBuddy *buddy; |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40853
diff
changeset
|
921 | PurpleConversation *im; |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
922 | |
|
40992
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
923 | 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
|
924 | continue; |
|
40992
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
925 | } |
|
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
926 | |
|
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
927 | buddy = PURPLE_BUDDY(child); |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
928 | |
|
40992
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
929 | im = purple_conversation_manager_find_im(manager, |
|
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
930 | purple_buddy_get_account(buddy), |
|
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
931 | purple_buddy_get_name(buddy)); |
|
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
932 | if(PURPLE_IS_IM_CONVERSATION(im)) { |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40853
diff
changeset
|
933 | purple_conversation_update(im, PURPLE_CONVERSATION_UPDATE_ICON); |
|
40992
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
934 | } |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
935 | |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
936 | /* 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
|
937 | * 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
|
938 | * icon changes? */ |
|
40992
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
939 | purple_blist_update_node(purple_blist_get_default(), child); |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
940 | } |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
941 | } else if (PURPLE_IS_CHAT(node)) { |
|
40992
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
942 | PurpleAccount *account = purple_chat_get_account(PURPLE_CHAT(node)); |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40853
diff
changeset
|
943 | PurpleConversation *chat = NULL; |
|
40992
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
944 | const gchar *name = purple_chat_get_name(PURPLE_CHAT(node)); |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
945 | |
|
40992
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
946 | chat = purple_conversation_manager_find_chat(manager, account, name); |
|
3a973a9c5a64
migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40889
diff
changeset
|
947 | if(PURPLE_IS_CHAT_CONVERSATION(chat)) { |
|
40885
87f6241da196
Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents:
40853
diff
changeset
|
948 | purple_conversation_update(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
|
949 | } |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
950 | } |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16440
diff
changeset
|
951 | |
|
39675
583e2ba6e78e
Add wrapper functions for some PurpleBlistUiOps.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39665
diff
changeset
|
952 | purple_blist_update_node(purple_blist_get_default(), node); |
|
23283
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
953 | |
|
93261f547412
Add the purple_buddy_icons_node_has_custom_icon,
Etan Reisner <deryni@pidgin.im>
parents:
22769
diff
changeset
|
954 | if (old_img) { |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
955 | 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
|
956 | } else if (old_icon) { |
|
16533
91e3e84b05f2
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@pidgin.im>
parents:
16532
diff
changeset
|
957 | /* 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
|
958 | * 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
|
959 | * 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
|
960 | 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
|
961 | } |
|
91e3e84b05f2
Fix a bug with removing custom buddy icons.
Richard Laager <rlaager@pidgin.im>
parents:
16532
diff
changeset
|
962 | 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
|
963 | |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16537
diff
changeset
|
964 | 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
|
965 | } |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
966 | |
|
35809
6dd40b244ce3
PurpleImage: convert buddyicon.c
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35458
diff
changeset
|
967 | PurpleImage * |
|
23285
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
968 | purple_buddy_icons_node_set_custom_icon_from_file(PurpleBlistNode *node, |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
969 | 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
|
970 | { |
|
24273
f5b589130c88
Don't try to read data from a NULL filename in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23285
diff
changeset
|
971 | 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
|
972 | 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
|
973 | |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
974 | 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
|
975 | |
|
41733
a9085b52de8b
Rename PurpleContact to PurpleMetaContact.
Gary Kramlich <grim@reaperworld.com>
parents:
41685
diff
changeset
|
976 | if (!PURPLE_IS_META_CONTACT(node) && |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
977 | !PURPLE_IS_CHAT(node) && |
|
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
978 | !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
|
979 | 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
|
980 | } |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
981 | |
|
24273
f5b589130c88
Don't try to read data from a NULL filename in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23285
diff
changeset
|
982 | 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
|
983 | 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
|
984 | 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
|
985 | } |
|
23285
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
986 | } |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
987 | |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
988 | 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
|
989 | } |
|
da6c923a5305
Add a purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Etan Reisner <deryni@pidgin.im>
parents:
23283
diff
changeset
|
990 | |
|
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
|
991 | static void |
|
16614
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
992 | delete_buddy_icon_settings(PurpleBlistNode *node, const char *setting_name) |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
993 | { |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
994 | purple_blist_node_remove_setting(node, setting_name); |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
995 | |
|
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
|
996 | 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
|
997 | { |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
998 | 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
|
999 | 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
|
1000 | } |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
1001 | } |
|
1cca48d1018b
nosnilmot had a problem with empty icon files.
Richard Laager <rlaager@pidgin.im>
parents:
16597
diff
changeset
|
1002 | |
|
41181
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1003 | static void |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1004 | _purple_buddy_icons_account_loaded_cb_helper(PurpleAccount *account, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1005 | gpointer data) |
|
16565
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1006 | { |
|
41181
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1007 | const gchar *dirname = (const gchar *)data; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1008 | const gchar *filename = NULL; |
|
16565
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1009 | |
|
41181
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1010 | filename = purple_account_get_string(account, "buddy_icon", NULL); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1011 | if(filename != NULL) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1012 | gchar *path = g_build_filename(dirname, filename, NULL); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1013 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1014 | if(!g_file_test(path, G_FILE_TEST_EXISTS)) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1015 | purple_account_set_string(account, "buddy_icon", NULL); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1016 | } else { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1017 | ref_filename(filename); |
|
16565
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1018 | } |
|
41181
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1019 | g_free(path); |
|
16565
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1020 | } |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1021 | } |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1022 | |
|
f5cd28cc7367
Ref the filenames for account buddy icons on load.
Richard Laager <rlaager@pidgin.im>
parents:
16544
diff
changeset
|
1023 | void |
|
41181
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1024 | _purple_buddy_icons_account_loaded_cb(void) |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1025 | { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1026 | PurpleAccountManager *manager = purple_account_manager_get_default(); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1027 | const char *dirname = purple_buddy_icons_get_cache_dir(); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1028 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1029 | purple_account_manager_foreach(manager, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1030 | _purple_buddy_icons_account_loaded_cb_helper, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1031 | (gpointer)dirname); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1032 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1033 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1034 | void |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40992
diff
changeset
|
1035 | _purple_buddy_icons_blist_loaded_cb(void) |
|
16421
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1036 | { |
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39461
diff
changeset
|
1037 | PurpleBlistNode *node = purple_blist_get_default_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
|
1038 | 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
|
1039 | |
|
16657
63e53570702c
Whitespace fix from patch in ticket #383
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16632
diff
changeset
|
1040 | 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
|
1041 | { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
1042 | 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
|
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 | 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
|
1045 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1046 | 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
|
1047 | 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
|
1048 | { |
|
31590
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1049 | char *path = g_build_filename(dirname, filename, NULL); |
|
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1050 | 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
|
1051 | { |
|
31590
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1052 | purple_blist_node_remove_setting(node, |
|
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1053 | "buddy_icon"); |
|
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1054 | purple_blist_node_remove_setting(node, |
|
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1055 | "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
|
1056 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1057 | else |
|
31590
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1058 | ref_filename(filename); |
|
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1059 | 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
|
1060 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1061 | } |
|
41733
a9085b52de8b
Rename PurpleContact to PurpleMetaContact.
Gary Kramlich <grim@reaperworld.com>
parents:
41685
diff
changeset
|
1062 | else if (PURPLE_IS_META_CONTACT(node) || |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
1063 | PURPLE_IS_CHAT(node) || |
|
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34645
diff
changeset
|
1064 | 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
|
1065 | { |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1066 | 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
|
1067 | |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1068 | 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
|
1069 | 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
|
1070 | { |
|
31590
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1071 | char *path = g_build_filename(dirname, filename, NULL); |
|
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1072 | 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
|
1073 | { |
|
31590
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1074 | purple_blist_node_remove_setting(node, |
|
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1075 | "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
|
1076 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1077 | else |
|
31590
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1078 | ref_filename(filename); |
|
e96aac3d0c77
Drop the .gaim -> .purple migration code
Richard Laager <rlaager@pidgin.im>
parents:
29296
diff
changeset
|
1079 | 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
|
1080 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1081 | } |
|
f9218e1c4703
The buddy icon code as it stands, with lots of bugs and design flaws.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1082 | 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
|
1083 | } |
| 6846 | 1084 | } |
| 1085 | ||
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1086 | void |
| 15884 | 1087 | purple_buddy_icons_set_caching(gboolean caching) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1088 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1089 | icon_caching = caching; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1090 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1091 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1092 | gboolean |
| 15884 | 1093 | purple_buddy_icons_is_caching(void) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1094 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1095 | return icon_caching; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1096 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1097 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1098 | void |
| 15884 | 1099 | purple_buddy_icons_set_cache_dir(const char *dir) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1100 | { |
|
10811
6b7ac5a9dd35
[gaim-migrate @ 12464]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
1101 | g_return_if_fail(dir != NULL); |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1102 | |
|
13934
c554909e9ff6
[gaim-migrate @ 16342]
Mark Doliner <markdoliner@pidgin.im>
parents:
13555
diff
changeset
|
1103 | g_free(cache_dir); |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1104 | cache_dir = g_strdup(dir); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1105 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1106 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1107 | const char * |
| 15884 | 1108 | purple_buddy_icons_get_cache_dir(void) |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1109 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1110 | return cache_dir; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1111 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1112 | |
| 6846 | 1113 | void * |
|
41840
fe350460fb1c
Remove C99-obsoleted constructs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41733
diff
changeset
|
1114 | purple_buddy_icons_get_handle(void) |
| 6846 | 1115 | { |
| 1116 | static int handle; | |
| 1117 | ||
| 1118 | return &handle; | |
| 1119 | } | |
| 1120 | ||
| 1121 | void | |
|
41840
fe350460fb1c
Remove C99-obsoleted constructs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41733
diff
changeset
|
1122 | purple_buddy_icons_init(void) |
| 6846 | 1123 | { |
| 1124 | account_cache = g_hash_table_new_full( | |
| 1125 | g_direct_hash, g_direct_equal, | |
| 1126 | NULL, (GFreeFunc)g_hash_table_destroy); | |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
1127 | |
|
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
|
1128 | 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
|
1129 | 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
|
1130 | 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
|
1131 | 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
|
1132 | 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
|
1133 | |
|
38870
575e41bfc15e
Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents:
37406
diff
changeset
|
1134 | if (!cache_dir) |
|
575e41bfc15e
Migrate certificates, icons, logs to XDG dirs
qarkai <qarkai@gmail.com>
parents:
37406
diff
changeset
|
1135 | cache_dir = g_build_filename(purple_cache_dir(), "icons", NULL); |
| 6846 | 1136 | } |
| 1137 | ||
| 1138 | void | |
|
41840
fe350460fb1c
Remove C99-obsoleted constructs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41733
diff
changeset
|
1139 | purple_buddy_icons_uninit(void) |
| 6846 | 1140 | { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16421
diff
changeset
|
1141 | 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
|
1142 | |
| 6846 | 1143 | 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
|
1144 | 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
|
1145 | 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
|
1146 | g_hash_table_destroy(pointer_icon_cache); |
|
42172
7c2d151b410d
Use g_clear_* helpers where useful
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41981
diff
changeset
|
1147 | g_clear_pointer(&cache_dir, g_free); |
| 6846 | 1148 | } |
| 10483 | 1149 | |
|
36624
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1150 | GType |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1151 | purple_buddy_icon_get_type(void) |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1152 | { |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1153 | static GType type = 0; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1154 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1155 | if (type == 0) { |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1156 | type = g_boxed_type_register_static("PurpleBuddyIcon", |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1157 | (GBoxedCopyFunc)purple_buddy_icon_ref, |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1158 | (GBoxedFreeFunc)purple_buddy_icon_unref); |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1159 | } |
|
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 | return type; |
| 6846 | 1162 | } |
| 10483 | 1163 | |
|
36624
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1164 | PurpleBuddyIconSpec * |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1165 | 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
|
1166 | int max_width, int max_height, size_t max_filesize, |
|
37406
98ec68212b1f
Move PurpleIconScaleRules to BuddyIcon API
Jorge Villaseñor <salinasv@pidgin.im>
parents:
37228
diff
changeset
|
1167 | PurpleBuddyIconScaleFlags scale_rules) |
|
36624
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1168 | { |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1169 | PurpleBuddyIconSpec *icon_spec; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1170 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1171 | icon_spec = g_new0(PurpleBuddyIconSpec, 1); |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1172 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1173 | icon_spec->format = format; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1174 | icon_spec->min_width = min_width; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1175 | icon_spec->min_height = min_height; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1176 | icon_spec->max_width = max_width; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1177 | icon_spec->max_height = max_height; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1178 | icon_spec->max_filesize = max_filesize; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1179 | icon_spec->scale_rules = scale_rules; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1180 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1181 | return icon_spec; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1182 | } |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1183 | |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40810
diff
changeset
|
1184 | void |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40810
diff
changeset
|
1185 | purple_buddy_icon_spec_free(PurpleBuddyIconSpec *spec) { |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40810
diff
changeset
|
1186 | if(spec == NULL) { |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40810
diff
changeset
|
1187 | return; |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40810
diff
changeset
|
1188 | } |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40810
diff
changeset
|
1189 | |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40810
diff
changeset
|
1190 | g_free(spec); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40810
diff
changeset
|
1191 | } |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40810
diff
changeset
|
1192 | |
|
36624
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1193 | static PurpleBuddyIconSpec * |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1194 | purple_buddy_icon_spec_copy(PurpleBuddyIconSpec *icon_spec) |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1195 | { |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1196 | PurpleBuddyIconSpec *icon_spec_copy; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1197 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1198 | 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
|
1199 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1200 | icon_spec_copy = g_new0(PurpleBuddyIconSpec, 1); |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1201 | *icon_spec_copy = *icon_spec; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1202 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1203 | return icon_spec_copy; |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1204 | } |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1205 | |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1206 | 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
|
1207 | int *width, int *height) |
| 10483 | 1208 | { |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1209 | int new_width, new_height; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1210 | |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1211 | new_width = *width; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1212 | new_height = *height; |
|
10523
ef52a88a8512
[gaim-migrate @ 11840]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10483
diff
changeset
|
1213 | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1214 | if (*width < spec->min_width) |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1215 | new_width = spec->min_width; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1216 | else if (*width > spec->max_width) |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1217 | new_width = spec->max_width; |
| 10483 | 1218 | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1219 | if (*height < spec->min_height) |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1220 | new_height = spec->min_height; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1221 | else if (*height > spec->max_height) |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1222 | new_height = spec->max_height; |
|
10523
ef52a88a8512
[gaim-migrate @ 11840]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10483
diff
changeset
|
1223 | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1224 | /* preserve aspect ratio */ |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1225 | if ((double)*height * (double)new_width > |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1226 | (double)*width * (double)new_height) { |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1227 | new_width = 0.5 + (double)*width * (double)new_height / (double)*height; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1228 | } else { |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1229 | new_height = 0.5 + (double)*height * (double)new_width / (double)*width; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1230 | } |
|
10523
ef52a88a8512
[gaim-migrate @ 11840]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10483
diff
changeset
|
1231 | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1232 | *width = new_width; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15135
diff
changeset
|
1233 | *height = new_height; |
| 10483 | 1234 | } |
|
34832
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1235 | |
|
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1236 | GType |
|
36624
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1237 | purple_buddy_icon_spec_get_type(void) |
|
34832
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1238 | { |
|
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1239 | static GType type = 0; |
|
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1240 | |
|
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1241 | if (type == 0) { |
|
36624
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1242 | type = g_boxed_type_register_static("PurpleBuddyIconSpec", |
|
38043ecaf4a6
Finished implementing functions for protocols.[ch].
Ankit Vani <a@nevitus.org>
parents:
36623
diff
changeset
|
1243 | (GBoxedCopyFunc)purple_buddy_icon_spec_copy, |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
40810
diff
changeset
|
1244 | (GBoxedFreeFunc)purple_buddy_icon_spec_free); |
|
34832
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1245 | } |
|
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1246 | |
|
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1247 | return type; |
|
3662bb1c9435
Backed out changeset 1feefa206b17
Ankit Vani <a@nevitus.org>
parents:
34829
diff
changeset
|
1248 | } |