Mercurial > pidgin
annotate libpurple/imgstore.c @ 24357:f108d707b6e1
Don't populate the password field on the modify account dialog if we are
not actually remembering it permanently
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sat, 01 Nov 2008 16:45:09 +0000 |
parents | 2f4b10ee752b |
children | 1643ace55ef8 |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /** |
22477
5a85bded9ae8
Add docs to PurpleStoredImage so that doxygen links to it show up
Will Thompson <will.thompson@collabora.co.uk>
parents:
20074
diff
changeset
|
2 * @file imgstore.c IM Image Store API |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * @ingroup core |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
4 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
5 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
6 /* purple |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
15822 | 8 * Purple is the legal property of its developers, whose names are too numerous |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * to list here. Please refer to the COPYRIGHT file distributed with this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * source distribution. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 * along with this program; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18340
diff
changeset
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 #include <glib.h> |
18202
7df46d8bf114
Move the define in internal.h instead.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17762
diff
changeset
|
29 #include "internal.h" |
7df46d8bf114
Move the define in internal.h instead.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17762
diff
changeset
|
30 |
17762
4bb617bd3d71
Get rid of a run-time dbus warning due to an unregistered storedimg.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16701
diff
changeset
|
31 #include "dbus-maybe.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 #include "imgstore.h" |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
34 #include "util.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
36 static GHashTable *imgstore; |
22624
e09650135f04
Add a little safety... just in case someone imgstores 13 million or
Mark Doliner <mark@kingant.net>
parents:
22623
diff
changeset
|
37 static unsigned int nextid = 0; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 |
22623 | 39 /* |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
40 * NOTE: purple_imgstore_add() creates these without zeroing the memory, so |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
41 * NOTE: make sure to update that function when adding members. |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 */ |
15822 | 43 struct _PurpleStoredImage |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 { |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
45 int id; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
46 guint8 refcount; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 size_t size; /**< The image data's size. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 char *filename; /**< The filename (for the UI) */ |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
49 gpointer data; /**< The image data. */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
52 PurpleStoredImage * |
16391
24bbd7e46bfe
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@wiktel.com>
parents:
16390
diff
changeset
|
53 purple_imgstore_add(gpointer data, size_t size, const char *filename) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 { |
15822 | 55 PurpleStoredImage *img; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 |
18340
e356256cb8a6
purple_imgstore_add() has checks which can lead it to return NULL (which should be NULL, not 0); purple_imgstore_add_with_id() should therefore allow for the possibility that the returned value is NULL and check it before using it. An id of 0 is returned if the function fails.
Evan Schoenberg <evan.s@dreskin.net>
parents:
18202
diff
changeset
|
57 g_return_val_if_fail(data != NULL, NULL); |
e356256cb8a6
purple_imgstore_add() has checks which can lead it to return NULL (which should be NULL, not 0); purple_imgstore_add_with_id() should therefore allow for the possibility that the returned value is NULL and check it before using it. An id of 0 is returned if the function fails.
Evan Schoenberg <evan.s@dreskin.net>
parents:
18202
diff
changeset
|
58 g_return_val_if_fail(size > 0, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 |
16381
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16376
diff
changeset
|
60 img = g_new(PurpleStoredImage, 1); |
17762
4bb617bd3d71
Get rid of a run-time dbus warning due to an unregistered storedimg.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16701
diff
changeset
|
61 PURPLE_DBUS_REGISTER_POINTER(img, PurpleStoredImage); |
16391
24bbd7e46bfe
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@wiktel.com>
parents:
16390
diff
changeset
|
62 img->data = data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 img->size = size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 img->filename = g_strdup(filename); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
65 img->refcount = 1; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
66 img->id = 0; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
68 return img; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
69 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
70 |
22511
0ae4d67bd6b1
Make it simple to create a stored-image from a filename.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
71 PurpleStoredImage * |
0ae4d67bd6b1
Make it simple to create a stored-image from a filename.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
72 purple_imgstore_new_from_file(const char *path) |
0ae4d67bd6b1
Make it simple to create a stored-image from a filename.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
73 { |
0ae4d67bd6b1
Make it simple to create a stored-image from a filename.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
74 gchar *data = NULL; |
0ae4d67bd6b1
Make it simple to create a stored-image from a filename.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
75 size_t len; |
0ae4d67bd6b1
Make it simple to create a stored-image from a filename.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
76 GError *err = NULL; |
0ae4d67bd6b1
Make it simple to create a stored-image from a filename.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
77 |
0ae4d67bd6b1
Make it simple to create a stored-image from a filename.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
78 if (!g_file_get_contents(path, &data, &len, &err)) { |
0ae4d67bd6b1
Make it simple to create a stored-image from a filename.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
79 purple_debug_error("imgstore", "Error reading %s: %s\n", |
0ae4d67bd6b1
Make it simple to create a stored-image from a filename.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
80 path, err->message); |
0ae4d67bd6b1
Make it simple to create a stored-image from a filename.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
81 g_error_free(err); |
0ae4d67bd6b1
Make it simple to create a stored-image from a filename.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
82 return NULL; |
0ae4d67bd6b1
Make it simple to create a stored-image from a filename.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
83 } |
0ae4d67bd6b1
Make it simple to create a stored-image from a filename.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
84 return purple_imgstore_add(data, len, path); |
0ae4d67bd6b1
Make it simple to create a stored-image from a filename.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
85 } |
0ae4d67bd6b1
Make it simple to create a stored-image from a filename.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
86 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
87 int |
16391
24bbd7e46bfe
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@wiktel.com>
parents:
16390
diff
changeset
|
88 purple_imgstore_add_with_id(gpointer data, size_t size, const char *filename) |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
89 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
90 PurpleStoredImage *img = purple_imgstore_add(data, size, filename); |
18340
e356256cb8a6
purple_imgstore_add() has checks which can lead it to return NULL (which should be NULL, not 0); purple_imgstore_add_with_id() should therefore allow for the possibility that the returned value is NULL and check it before using it. An id of 0 is returned if the function fails.
Evan Schoenberg <evan.s@dreskin.net>
parents:
18202
diff
changeset
|
91 if (img) { |
22624
e09650135f04
Add a little safety... just in case someone imgstores 13 million or
Mark Doliner <mark@kingant.net>
parents:
22623
diff
changeset
|
92 /* |
e09650135f04
Add a little safety... just in case someone imgstores 13 million or
Mark Doliner <mark@kingant.net>
parents:
22623
diff
changeset
|
93 * Use the next unused id number. We do it in a loop on the |
e09650135f04
Add a little safety... just in case someone imgstores 13 million or
Mark Doliner <mark@kingant.net>
parents:
22623
diff
changeset
|
94 * off chance that nextid wraps back around to 0 and the hash |
e09650135f04
Add a little safety... just in case someone imgstores 13 million or
Mark Doliner <mark@kingant.net>
parents:
22623
diff
changeset
|
95 * table still contains entries from the first time around. |
e09650135f04
Add a little safety... just in case someone imgstores 13 million or
Mark Doliner <mark@kingant.net>
parents:
22623
diff
changeset
|
96 */ |
e09650135f04
Add a little safety... just in case someone imgstores 13 million or
Mark Doliner <mark@kingant.net>
parents:
22623
diff
changeset
|
97 do { |
e09650135f04
Add a little safety... just in case someone imgstores 13 million or
Mark Doliner <mark@kingant.net>
parents:
22623
diff
changeset
|
98 img->id = ++nextid; |
e09650135f04
Add a little safety... just in case someone imgstores 13 million or
Mark Doliner <mark@kingant.net>
parents:
22623
diff
changeset
|
99 } while (img->id == 0 || g_hash_table_lookup(imgstore, &(img->id)) != NULL); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
100 |
18340
e356256cb8a6
purple_imgstore_add() has checks which can lead it to return NULL (which should be NULL, not 0); purple_imgstore_add_with_id() should therefore allow for the possibility that the returned value is NULL and check it before using it. An id of 0 is returned if the function fails.
Evan Schoenberg <evan.s@dreskin.net>
parents:
18202
diff
changeset
|
101 g_hash_table_insert(imgstore, &(img->id), img); |
e356256cb8a6
purple_imgstore_add() has checks which can lead it to return NULL (which should be NULL, not 0); purple_imgstore_add_with_id() should therefore allow for the possibility that the returned value is NULL and check it before using it. An id of 0 is returned if the function fails.
Evan Schoenberg <evan.s@dreskin.net>
parents:
18202
diff
changeset
|
102 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
103 |
18340
e356256cb8a6
purple_imgstore_add() has checks which can lead it to return NULL (which should be NULL, not 0); purple_imgstore_add_with_id() should therefore allow for the possibility that the returned value is NULL and check it before using it. An id of 0 is returned if the function fails.
Evan Schoenberg <evan.s@dreskin.net>
parents:
18202
diff
changeset
|
104 return (img ? img->id : 0); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
105 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
106 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
107 PurpleStoredImage *purple_imgstore_find_by_id(int id) { |
16507
e340dc515178
disapproval of revision 'a999246dfcbd33c9494afa445d9562aee5e5457c'
Richard Laager <rlaager@wiktel.com>
parents:
16506
diff
changeset
|
108 PurpleStoredImage *img = g_hash_table_lookup(imgstore, &id); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
110 if (img != NULL) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
111 purple_debug_misc("imgstore", "retrieved image id %d\n", img->id); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
112 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
113 return img; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
114 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
115 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
116 gconstpointer purple_imgstore_get_data(PurpleStoredImage *img) { |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
117 g_return_val_if_fail(img != NULL, NULL); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
118 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
119 return img->data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
121 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
122 size_t purple_imgstore_get_size(PurpleStoredImage *img) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
123 { |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
124 g_return_val_if_fail(img != NULL, 0); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
125 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
126 return img->size; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
127 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 |
16701
77cfd9bd6536
Get rid of two harmless warnings:
Mark Doliner <mark@kingant.net>
parents:
16587
diff
changeset
|
129 const char *purple_imgstore_get_filename(const PurpleStoredImage *img) |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
130 { |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
131 g_return_val_if_fail(img != NULL, NULL); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
132 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
133 return img->filename; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
134 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
135 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
136 const char *purple_imgstore_get_extension(PurpleStoredImage *img) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
137 { |
16390
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
138 g_return_val_if_fail(img != NULL, NULL); |
4fc51a87ce42
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents:
16381
diff
changeset
|
139 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
140 return purple_util_get_image_extension(img->data, img->size); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
143 void purple_imgstore_ref_by_id(int id) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
144 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
145 PurpleStoredImage *img = purple_imgstore_find_by_id(id); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
146 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
147 g_return_if_fail(img != NULL); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
148 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
149 purple_imgstore_ref(img); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
150 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
151 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
152 void purple_imgstore_unref_by_id(int id) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
153 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
154 PurpleStoredImage *img = purple_imgstore_find_by_id(id); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
155 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
156 g_return_if_fail(img != NULL); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
157 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
158 purple_imgstore_unref(img); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
159 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
161 PurpleStoredImage * |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
162 purple_imgstore_ref(PurpleStoredImage *img) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
163 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
164 g_return_val_if_fail(img != NULL, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
166 img->refcount++; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
167 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
168 return img; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
171 PurpleStoredImage * |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
172 purple_imgstore_unref(PurpleStoredImage *img) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
173 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
174 if (img == NULL) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
175 return NULL; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
176 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
177 g_return_val_if_fail(img->refcount > 0, NULL); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
178 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
179 img->refcount--; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
181 if (img->refcount == 0) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
182 { |
16376
dd47fa8ba3e4
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
Richard Laager <rlaager@wiktel.com>
parents:
16375
diff
changeset
|
183 purple_signal_emit(purple_imgstore_get_handle(), |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
184 "image-deleting", img); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
185 if (img->id) |
16507
e340dc515178
disapproval of revision 'a999246dfcbd33c9494afa445d9562aee5e5457c'
Richard Laager <rlaager@wiktel.com>
parents:
16506
diff
changeset
|
186 g_hash_table_remove(imgstore, &img->id); |
16381
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16376
diff
changeset
|
187 |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16376
diff
changeset
|
188 g_free(img->data); |
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16376
diff
changeset
|
189 g_free(img->filename); |
17762
4bb617bd3d71
Get rid of a run-time dbus warning due to an unregistered storedimg.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16701
diff
changeset
|
190 PURPLE_DBUS_UNREGISTER_POINTER(img); |
16381
72dc611f3257
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents:
16376
diff
changeset
|
191 g_free(img); |
16587
f2d2df46e68e
Part of the patch in ticket #383:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16527
diff
changeset
|
192 img = NULL; |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
193 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
194 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
195 return img; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
196 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
198 void * |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
199 purple_imgstore_get_handle() |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
200 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
201 static int handle; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
203 return &handle; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
204 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
205 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
206 void |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
207 purple_imgstore_init() |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
208 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
209 void *handle = purple_imgstore_get_handle(); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
211 purple_signal_register(handle, "image-deleting", |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
212 purple_marshal_VOID__POINTER, NULL, |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
213 1, |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
214 purple_value_new(PURPLE_TYPE_SUBTYPE, |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
215 PURPLE_SUBTYPE_STORED_IMAGE)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
217 imgstore = g_hash_table_new(g_int_hash, g_int_equal); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
218 } |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
219 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
220 void |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
221 purple_imgstore_uninit() |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
222 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
223 g_hash_table_destroy(imgstore); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
224 |
16527
1d3d54e964ce
Fix a bug in the imgstore code that I caught because of the fatal asserts in the test code.
Richard Laager <rlaager@wiktel.com>
parents:
16507
diff
changeset
|
225 purple_signals_unregister_by_instance(purple_imgstore_get_handle()); |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
226 } |