Mercurial > pidgin
annotate libpurple/smiley.c @ 23137:53b3c75c9e26
Separate the custom smileys from the regular smileys, and add a 'Manage'
button in the smiley dialog for the custom smileys. This should make it
more obvious that custom smileys are supported (do we actually want it to
be? ;) )
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 11 May 2008 04:04:35 +0000 |
parents | 6c4f47b9d201 |
children | f1df88964b3d |
rev | line source |
---|---|
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1 /** |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
2 * @file smiley.c Simley API |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
3 * @ingroup core |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
4 */ |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
5 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
6 /* purple |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
7 * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
8 * Purple is the legal property of its developers, whose names are too numerous |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
9 * to list here. Please refer to the COPYRIGHT file distributed with this |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
10 * source distribution. |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
11 * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
12 * This program is free software; you can redistribute it and/or modify |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
13 * it under the terms of the GNU General Public License as published by |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
14 * the Free Software Foundation; either version 2 of the License, or |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
15 * (at your option) any later version. |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
16 * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
17 * This program is distributed in the hope that it will be useful, |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
20 * GNU General Public License for more details. |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
21 * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
22 * You should have received a copy of the GNU General Public License |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
23 * along with this program; if not, write to the Free Software |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
25 */ |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
26 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
27 #include "internal.h" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
28 #include "xmlnode.h" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
29 #include "debug.h" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
30 #include "imgstore.h" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
31 #include "smiley.h" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
32 #include "util.h" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
33 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
34 /**************************************************************************/ |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
35 /* Main structures, members and constants */ |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
36 /**************************************************************************/ |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
37 |
22317
2ab289f312d0
Hide PurpleSmiley internals.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22314
diff
changeset
|
38 struct _PurpleSmiley |
2ab289f312d0
Hide PurpleSmiley internals.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22314
diff
changeset
|
39 { |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
40 GObject parent; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
41 PurpleStoredImage *img; /**< The id of the stored image with the |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
42 the smiley data. */ |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
43 char *shortcut; /**< Shortcut associated with the custom |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
44 smiley. This field will work as a |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
45 unique key by this API. */ |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
46 char *checksum; /**< The smiley checksum. */ |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
47 }; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
48 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
49 struct _PurpleSmileyClass |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
50 { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
51 GObjectClass parent_class; |
22317
2ab289f312d0
Hide PurpleSmiley internals.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22314
diff
changeset
|
52 }; |
2ab289f312d0
Hide PurpleSmiley internals.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22314
diff
changeset
|
53 |
22319
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
54 static GHashTable *smiley_shortcut_index = NULL; /* shortcut (char *) => smiley (PurpleSmiley*) */ |
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
55 static GHashTable *smiley_checksum_index = NULL; /* checksum (char *) => smiley (PurpleSmiley*) */ |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
56 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
57 static guint save_timer = 0; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
58 static gboolean smileys_loaded = FALSE; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
59 static char *smileys_dir = NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
60 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
61 #define SMILEYS_DEFAULT_FOLDER "custom_smiley" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
62 #define SMILEYS_LOG_ID "smileys" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
63 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
64 #define XML_FILE_NAME "smileys.xml" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
65 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
66 #define XML_ROOT_TAG "smileys" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
67 #define XML_PROFILE_TAG "profile" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
68 #define XML_PROFILE_NAME_ATTRIB_TAG "name" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
69 #define XML_ACCOUNT_TAG "account" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
70 #define XML_ACCOUNT_USERID_ATTRIB_TAG "userid" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
71 #define XML_SMILEY_SET_TAG "smiley_set" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
72 #define XML_SMILEY_TAG "smiley" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
73 #define XML_SHORTCUT_ATTRIB_TAG "shortcut" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
74 #define XML_CHECKSUM_ATRIB_TAG "checksum" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
75 #define XML_FILENAME_ATRIB_TAG "filename" |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
76 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
77 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
78 /****************************************************************************** |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
79 * XML descriptor file layout * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
80 ****************************************************************************** |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
81 * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
82 * Althought we are creating the profile XML structure here, now we |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
83 * won't handle it. |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
84 * So, we just add one profile named "default" that has no associated |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
85 * account elements, and have only the smiley_set that will contain |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
86 * all existent custom smiley. |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
87 * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
88 * It's our "Highlander Profile" :-) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
89 * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
90 ****************************************************************************** |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
91 * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
92 * <smileys> |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
93 * <profile name="john.doe"> |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
94 * <account userid="john.doe@jabber.org"> |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
95 * <account userid="john.doe@gmail.com"> |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
96 * <smiley_set> |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
97 * <smiley shortcut="aaa" checksum="xxxxxxxx" filename="file_name1.gif"/> |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
98 * <smiley shortcut="bbb" checksum="yyyyyyy" filename="file_name2.gif"/> |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
99 * </smiley_set> |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
100 * </profile> |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
101 * </smiley> |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
102 * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
103 *****************************************************************************/ |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
104 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
105 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
106 /********************************************************************* |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
107 * Forward declarations * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
108 *********************************************************************/ |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
109 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
110 static gboolean read_smiley_file(const char *path, guchar **data, size_t *len); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
111 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
112 static char *get_file_full_path(const char *filename); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
113 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
114 static PurpleSmiley *purple_smiley_create(const char *shortcut); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
115 |
22314
76fa93017695
Make some functions static, plug a leak.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22311
diff
changeset
|
116 static PurpleSmiley *purple_smiley_load_file(const char *shortcut, const char *checksum, |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
117 const char *filename); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
118 |
22314
76fa93017695
Make some functions static, plug a leak.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22311
diff
changeset
|
119 static void |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
120 purple_smiley_set_data_impl(PurpleSmiley *smiley, guchar *smiley_data, |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
121 size_t smiley_data_len, const char *filename); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
122 |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
123 static void |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
124 purple_smiley_data_store(PurpleStoredImage *stored_img); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
125 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
126 static void |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
127 purple_smiley_data_unstore(const char *filename); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
128 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
129 /********************************************************************* |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
130 * Writing to disk * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
131 *********************************************************************/ |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
132 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
133 static xmlnode * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
134 smiley_to_xmlnode(PurpleSmiley *smiley) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
135 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
136 xmlnode *smiley_node = NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
137 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
138 smiley_node = xmlnode_new(XML_SMILEY_TAG); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
139 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
140 if (!smiley_node) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
141 return NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
142 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
143 xmlnode_set_attrib(smiley_node, XML_SHORTCUT_ATTRIB_TAG, |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
144 smiley->shortcut); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
145 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
146 xmlnode_set_attrib(smiley_node, XML_CHECKSUM_ATRIB_TAG, |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
147 smiley->checksum); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
148 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
149 xmlnode_set_attrib(smiley_node, XML_FILENAME_ATRIB_TAG, |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
150 purple_imgstore_get_filename(smiley->img)); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
151 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
152 return smiley_node; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
153 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
154 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
155 static void |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
156 add_smiley_to_main_node(gpointer key, gpointer value, gpointer user_data) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
157 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
158 xmlnode *child_node; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
159 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
160 child_node = smiley_to_xmlnode(value); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
161 xmlnode_insert_child((xmlnode*)user_data, child_node); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
162 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
163 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
164 static xmlnode * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
165 smileys_to_xmlnode() |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
166 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
167 xmlnode *root_node, *profile_node, *smileyset_node; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
168 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
169 root_node = xmlnode_new(XML_ROOT_TAG); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
170 xmlnode_set_attrib(root_node, "version", "1.0"); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
171 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
172 /* See the top comment's above to understand why initial tag elements |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
173 * are not being considered by now. */ |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
174 profile_node = xmlnode_new(XML_PROFILE_TAG); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
175 if (profile_node) { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
176 xmlnode_set_attrib(profile_node, XML_PROFILE_NAME_ATTRIB_TAG, "Default"); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
177 xmlnode_insert_child(root_node, profile_node); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
178 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
179 smileyset_node = xmlnode_new(XML_SMILEY_SET_TAG); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
180 if (smileyset_node) { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
181 xmlnode_insert_child(profile_node, smileyset_node); |
22319
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
182 g_hash_table_foreach(smiley_shortcut_index, add_smiley_to_main_node, smileyset_node); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
183 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
184 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
185 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
186 return root_node; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
187 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
188 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
189 static void |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
190 sync_smileys() |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
191 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
192 xmlnode *root_node; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
193 char *data; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
194 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
195 if (!smileys_loaded) { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
196 purple_debug_error(SMILEYS_LOG_ID, "Attempted to save smileys before it " |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
197 "was read!\n"); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
198 return; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
199 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
200 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
201 root_node = smileys_to_xmlnode(); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
202 data = xmlnode_to_formatted_str(root_node, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
203 purple_util_write_data_to_file(XML_FILE_NAME, data, -1); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
204 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
205 g_free(data); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
206 xmlnode_free(root_node); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
207 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
208 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
209 static gboolean |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
210 save_smileys_cb(gpointer data) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
211 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
212 sync_smileys(); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
213 save_timer = 0; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
214 return FALSE; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
215 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
216 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
217 static void |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
218 purple_smileys_save() |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
219 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
220 if (save_timer == 0) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
221 save_timer = purple_timeout_add_seconds(5, save_smileys_cb, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
222 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
223 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
224 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
225 /********************************************************************* |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
226 * Reading from disk * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
227 *********************************************************************/ |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
228 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
229 static PurpleSmiley * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
230 parse_smiley(xmlnode *smiley_node) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
231 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
232 PurpleSmiley *smiley; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
233 const char *shortcut = NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
234 const char *checksum = NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
235 const char *filename = NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
236 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
237 shortcut = xmlnode_get_attrib(smiley_node, XML_SHORTCUT_ATTRIB_TAG); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
238 checksum = xmlnode_get_attrib(smiley_node, XML_CHECKSUM_ATRIB_TAG); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
239 filename = xmlnode_get_attrib(smiley_node, XML_FILENAME_ATRIB_TAG); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
240 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
241 if ((shortcut == NULL) || (checksum == NULL) || (filename == NULL)) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
242 return NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
243 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
244 smiley = purple_smiley_load_file(shortcut, checksum, filename); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
245 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
246 return smiley; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
247 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
248 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
249 static void |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
250 purple_smileys_load() |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
251 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
252 xmlnode *root_node, *profile_node; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
253 xmlnode *smileyset_node = NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
254 xmlnode *smiley_node; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
255 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
256 smileys_loaded = TRUE; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
257 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
258 root_node = purple_util_read_xml_from_file(XML_FILE_NAME, |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
259 _(SMILEYS_LOG_ID)); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
260 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
261 if (root_node == NULL) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
262 return; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
263 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
264 /* See the top comment's above to understand why initial tag elements |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
265 * are not being considered by now. */ |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
266 profile_node = xmlnode_get_child(root_node, XML_PROFILE_TAG); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
267 if (profile_node) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
268 smileyset_node = xmlnode_get_child(profile_node, XML_SMILEY_SET_TAG); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
269 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
270 if (smileyset_node) { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
271 smiley_node = xmlnode_get_child(smileyset_node, XML_SMILEY_TAG); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
272 for (; smiley_node != NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
273 smiley_node = xmlnode_get_next_twin(smiley_node)) { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
274 PurpleSmiley *smiley; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
275 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
276 smiley = parse_smiley(smiley_node); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
277 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
278 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
279 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
280 xmlnode_free(root_node); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
281 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
282 |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
283 /********************************************************************* |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
284 * GObject Stuff * |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
285 *********************************************************************/ |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
286 enum |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
287 { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
288 PROP_0, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
289 PROP_SHORTCUT, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
290 PROP_IMGSTORE, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
291 }; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
292 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
293 #define PROP_SHORTCUT_S "shortcut" |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
294 #define PROP_IMGSTORE_S "image" |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
295 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
296 enum |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
297 { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
298 SIG_DESTROY, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
299 SIG_LAST |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
300 }; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
301 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
302 static guint signals[SIG_LAST]; |
23137
53b3c75c9e26
Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23134
diff
changeset
|
303 static GObjectClass *parent_class; |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
304 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
305 static void |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
306 purple_smiley_init(GTypeInstance *instance, gpointer klass) |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
307 { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
308 } |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
309 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
310 static void |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
311 purple_smiley_get_property(GObject *object, guint param_id, GValue *value, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
312 GParamSpec *spec) |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
313 { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
314 PurpleSmiley *smiley = PURPLE_SMILEY(object); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
315 switch (param_id) { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
316 case PROP_SHORTCUT: |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
317 g_value_set_string(value, smiley->shortcut); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
318 break; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
319 case PROP_IMGSTORE: |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
320 g_value_set_pointer(value, smiley->img); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
321 break; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
322 default: |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
323 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, spec); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
324 break; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
325 } |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
326 } |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
327 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
328 static void |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
329 purple_smiley_set_property(GObject *object, guint param_id, const GValue *value, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
330 GParamSpec *spec) |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
331 { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
332 PurpleSmiley *smiley = PURPLE_SMILEY(object); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
333 switch (param_id) { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
334 case PROP_SHORTCUT: |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
335 { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
336 const char *shortcut = g_value_get_string(value); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
337 purple_smiley_set_shortcut(smiley, shortcut); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
338 } |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
339 break; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
340 case PROP_IMGSTORE: |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
341 { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
342 PurpleStoredImage *img = g_value_get_pointer(value); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
343 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
344 purple_imgstore_unref(smiley->img); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
345 g_free(smiley->checksum); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
346 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
347 smiley->img = img; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
348 if (img) { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
349 smiley->checksum = purple_util_get_image_checksum( |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
350 purple_imgstore_get_data(img), |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
351 purple_imgstore_get_size(img)); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
352 purple_smiley_data_store(img); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
353 } else { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
354 smiley->checksum = NULL; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
355 } |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
356 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
357 g_object_notify(object, PROP_IMGSTORE_S); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
358 } |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
359 break; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
360 default: |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
361 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, spec); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
362 break; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
363 } |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
364 } |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
365 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
366 static void |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
367 purple_smiley_finalize(GObject *obj) |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
368 { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
369 PurpleSmiley *smiley = PURPLE_SMILEY(obj); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
370 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
371 if (g_hash_table_lookup(smiley_shortcut_index, smiley->shortcut)) { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
372 g_hash_table_remove(smiley_shortcut_index, smiley->shortcut); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
373 g_hash_table_remove(smiley_checksum_index, smiley->checksum); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
374 } |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
375 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
376 g_free(smiley->shortcut); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
377 g_free(smiley->checksum); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
378 if (smiley->img) |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
379 purple_smiley_data_unstore(purple_imgstore_get_filename(smiley->img)); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
380 purple_imgstore_unref(smiley->img); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
381 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
382 purple_smileys_save(); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
383 } |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
384 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
385 static void |
23137
53b3c75c9e26
Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23134
diff
changeset
|
386 purple_smiley_dispose(GObject *gobj) |
53b3c75c9e26
Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23134
diff
changeset
|
387 { |
53b3c75c9e26
Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23134
diff
changeset
|
388 g_signal_emit(gobj, signals[SIG_DESTROY], 0); |
53b3c75c9e26
Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23134
diff
changeset
|
389 parent_class->dispose(gobj); |
53b3c75c9e26
Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23134
diff
changeset
|
390 } |
53b3c75c9e26
Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23134
diff
changeset
|
391 |
53b3c75c9e26
Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23134
diff
changeset
|
392 static void |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
393 purple_smiley_class_init(PurpleSmileyClass *klass) |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
394 { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
395 GObjectClass *gobj_class = G_OBJECT_CLASS(klass); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
396 GParamSpec *pspec; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
397 |
23137
53b3c75c9e26
Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23134
diff
changeset
|
398 parent_class = g_type_class_peek_parent(klass); |
53b3c75c9e26
Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23134
diff
changeset
|
399 |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
400 gobj_class->get_property = purple_smiley_get_property; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
401 gobj_class->set_property = purple_smiley_set_property; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
402 gobj_class->finalize = purple_smiley_finalize; |
23137
53b3c75c9e26
Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23134
diff
changeset
|
403 gobj_class->dispose = purple_smiley_dispose; |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
404 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
405 /* Shortcut */ |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
406 pspec = g_param_spec_string(PROP_SHORTCUT_S, _("Shortcut"), |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
407 _("The text-shortcut for the smiley"), |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
408 NULL, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
409 G_PARAM_READWRITE); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
410 g_object_class_install_property(gobj_class, PROP_SHORTCUT, pspec); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
411 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
412 /* Stored Image */ |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
413 pspec = g_param_spec_pointer(PROP_IMGSTORE_S, _("Stored Image"), |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
414 _("Stored Image. (that'll have to do for now)"), |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
415 G_PARAM_READWRITE); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
416 g_object_class_install_property(gobj_class, PROP_IMGSTORE, pspec); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
417 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
418 signals[SIG_DESTROY] = g_signal_new("destroy", |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
419 G_OBJECT_CLASS_TYPE(klass), |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
420 G_SIGNAL_RUN_LAST, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
421 0, NULL, NULL, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
422 g_cclosure_marshal_VOID__VOID, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
423 G_TYPE_NONE, 0); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
424 } |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
425 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
426 GType |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
427 purple_smiley_get_type(void) |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
428 { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
429 static GType type = 0; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
430 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
431 if(type == 0) { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
432 static const GTypeInfo info = { |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
433 sizeof(PurpleSmileyClass), |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
434 NULL, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
435 NULL, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
436 (GClassInitFunc)purple_smiley_class_init, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
437 NULL, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
438 NULL, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
439 sizeof(PurpleSmiley), |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
440 0, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
441 purple_smiley_init, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
442 NULL, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
443 }; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
444 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
445 type = g_type_register_static(G_TYPE_OBJECT, |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
446 "PurpleSmiley", |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
447 &info, 0); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
448 } |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
449 |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
450 return type; |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
451 } |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
452 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
453 /********************************************************************* |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
454 * Other Stuff * |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
455 *********************************************************************/ |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
456 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
457 static char *get_file_full_path(const char *filename) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
458 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
459 char *path; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
460 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
461 path = g_build_filename(purple_smileys_get_storing_dir(), filename, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
462 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
463 if (!g_file_test(path, G_FILE_TEST_EXISTS)) { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
464 g_free(path); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
465 return NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
466 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
467 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
468 return path; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
469 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
470 |
22314
76fa93017695
Make some functions static, plug a leak.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22311
diff
changeset
|
471 static PurpleSmiley * |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
472 purple_smiley_load_file(const char *shortcut, const char *checksum, const char *filename) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
473 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
474 PurpleSmiley *smiley = NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
475 guchar *smiley_data; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
476 size_t smiley_data_len; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
477 char *fullpath = NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
478 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
479 g_return_val_if_fail(shortcut != NULL, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
480 g_return_val_if_fail(checksum != NULL, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
481 g_return_val_if_fail(filename != NULL, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
482 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
483 fullpath = get_file_full_path(filename); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
484 if (!fullpath) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
485 return NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
486 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
487 smiley = purple_smiley_create(shortcut); |
22314
76fa93017695
Make some functions static, plug a leak.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22311
diff
changeset
|
488 if (!smiley) { |
76fa93017695
Make some functions static, plug a leak.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22311
diff
changeset
|
489 g_free(fullpath); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
490 return NULL; |
22314
76fa93017695
Make some functions static, plug a leak.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22311
diff
changeset
|
491 } |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
492 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
493 smiley->checksum = g_strdup(checksum); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
494 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
495 if (read_smiley_file(fullpath, &smiley_data, &smiley_data_len)) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
496 purple_smiley_set_data_impl(smiley, smiley_data, |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
497 smiley_data_len, filename); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
498 else |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
499 purple_smiley_delete(smiley); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
500 |
22314
76fa93017695
Make some functions static, plug a leak.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22311
diff
changeset
|
501 g_free(fullpath); |
76fa93017695
Make some functions static, plug a leak.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22311
diff
changeset
|
502 |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
503 return smiley; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
504 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
505 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
506 static void |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
507 purple_smiley_data_store(PurpleStoredImage *stored_img) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
508 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
509 const char *dirname; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
510 char *path; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
511 FILE *file = NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
512 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
513 g_return_if_fail(stored_img != NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
514 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
515 if (!smileys_loaded) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
516 return; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
517 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
518 dirname = purple_smileys_get_storing_dir(); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
519 path = g_build_filename(dirname, purple_imgstore_get_filename(stored_img), NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
520 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
521 if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
522 purple_debug_info(SMILEYS_LOG_ID, "Creating smileys directory.\n"); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
523 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
524 if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
525 purple_debug_error(SMILEYS_LOG_ID, |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
526 "Unable to create directory %s: %s\n", |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
527 dirname, g_strerror(errno)); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
528 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
529 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
530 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
531 if ((file = g_fopen(path, "wb")) != NULL) { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
532 if (!fwrite(purple_imgstore_get_data(stored_img), |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
533 purple_imgstore_get_size(stored_img), 1, file)) { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
534 purple_debug_error(SMILEYS_LOG_ID, "Error writing %s: %s\n", |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
535 path, g_strerror(errno)); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
536 } else { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
537 purple_debug_info(SMILEYS_LOG_ID, "Wrote cache file: %s\n", path); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
538 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
539 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
540 fclose(file); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
541 } else { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
542 purple_debug_error(SMILEYS_LOG_ID, "Unable to create file %s: %s\n", |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
543 path, g_strerror(errno)); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
544 g_free(path); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
545 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
546 return; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
547 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
548 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
549 g_free(path); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
550 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
551 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
552 static void |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
553 purple_smiley_data_unstore(const char *filename) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
554 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
555 const char *dirname; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
556 char *path; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
557 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
558 g_return_if_fail(filename != NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
559 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
560 dirname = purple_smileys_get_storing_dir(); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
561 path = g_build_filename(dirname, filename, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
562 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
563 if (g_file_test(path, G_FILE_TEST_EXISTS)) { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
564 if (g_unlink(path)) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
565 purple_debug_error(SMILEYS_LOG_ID, "Failed to delete %s: %s\n", |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
566 path, g_strerror(errno)); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
567 else |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
568 purple_debug_info(SMILEYS_LOG_ID, "Deleted cache file: %s\n", path); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
569 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
570 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
571 g_free(path); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
572 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
573 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
574 static gboolean |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
575 read_smiley_file(const char *path, guchar **data, size_t *len) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
576 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
577 GError *err = NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
578 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
579 if (!g_file_get_contents(path, (gchar **)data, len, &err)) { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
580 purple_debug_error(SMILEYS_LOG_ID, "Error reading %s: %s\n", |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
581 path, err->message); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
582 g_error_free(err); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
583 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
584 return FALSE; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
585 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
586 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
587 return TRUE; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
588 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
589 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
590 static PurpleStoredImage * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
591 purple_smiley_data_new(guchar *smiley_data, size_t smiley_data_len) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
592 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
593 char *filename; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
594 PurpleStoredImage *stored_img; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
595 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
596 g_return_val_if_fail(smiley_data != NULL, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
597 g_return_val_if_fail(smiley_data_len > 0, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
598 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
599 filename = purple_util_get_image_filename(smiley_data, smiley_data_len); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
600 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
601 if (filename == NULL) { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
602 g_free(smiley_data); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
603 return NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
604 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
605 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
606 stored_img = purple_imgstore_add(smiley_data, smiley_data_len, filename); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
607 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
608 g_free(filename); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
609 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
610 return stored_img; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
611 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
612 |
22314
76fa93017695
Make some functions static, plug a leak.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22311
diff
changeset
|
613 static void |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
614 purple_smiley_set_data_impl(PurpleSmiley *smiley, guchar *smiley_data, |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
615 size_t smiley_data_len, const char *filename) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
616 { |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
617 PurpleStoredImage *old_img, *new_img; |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
618 const char *old_filename = NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
619 const char *new_filename = NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
620 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
621 g_return_if_fail(smiley != NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
622 g_return_if_fail(smiley_data != NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
623 g_return_if_fail(smiley_data_len > 0); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
624 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
625 old_img = smiley->img; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
626 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
627 if (filename) |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
628 new_img = purple_imgstore_add(smiley_data, smiley_data_len, filename); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
629 else |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
630 new_img = purple_smiley_data_new(smiley_data, smiley_data_len); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
631 |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
632 g_object_set(G_OBJECT(smiley), PROP_IMGSTORE_S, new_img, NULL); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
633 |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
634 /* If the old and new image files have different names we need |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
635 * to unstore old image file. */ |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
636 if (!old_img) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
637 return; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
638 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
639 old_filename = purple_imgstore_get_filename(old_img); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
640 new_filename = purple_imgstore_get_filename(smiley->img); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
641 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
642 if (g_ascii_strcasecmp(old_filename, new_filename)) { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
643 purple_smiley_data_unstore(old_filename); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
644 purple_imgstore_unref(old_img); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
645 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
646 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
647 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
648 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
649 /***************************************************************************** |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
650 * Public API functions * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
651 *****************************************************************************/ |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
652 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
653 static PurpleSmiley * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
654 purple_smiley_create(const char *shortcut) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
655 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
656 PurpleSmiley *smiley; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
657 |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
658 smiley = PURPLE_SMILEY(g_object_new(PURPLE_TYPE_SMILEY, PROP_SHORTCUT_S, shortcut, NULL)); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
659 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
660 return smiley; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
661 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
662 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
663 PurpleSmiley * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
664 purple_smiley_new(PurpleStoredImage *img, const char *shortcut) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
665 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
666 PurpleSmiley *smiley = NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
667 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
668 g_return_val_if_fail(shortcut != NULL, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
669 g_return_val_if_fail(img != NULL, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
670 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
671 smiley = purple_smileys_find_by_shortcut(shortcut); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
672 if (smiley) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
673 return smiley; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
674 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
675 smiley = purple_smiley_create(shortcut); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
676 if (!smiley) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
677 return NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
678 |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
679 g_object_set(G_OBJECT(smiley), PROP_IMGSTORE_S, img, NULL); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
680 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
681 return smiley; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
682 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
683 |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
684 static PurpleSmiley * |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
685 purple_smiley_new_from_stream(const char *shortcut, guchar *smiley_data, |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
686 size_t smiley_data_len, const char *filename) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
687 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
688 PurpleSmiley *smiley; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
689 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
690 g_return_val_if_fail(shortcut != NULL, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
691 g_return_val_if_fail(smiley_data != NULL, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
692 g_return_val_if_fail(smiley_data_len > 0, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
693 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
694 smiley = purple_smileys_find_by_shortcut(shortcut); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
695 if (smiley) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
696 return smiley; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
697 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
698 /* purple_smiley_create() sets shortcut */ |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
699 smiley = purple_smiley_create(shortcut); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
700 if (!smiley) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
701 return NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
702 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
703 purple_smiley_set_data_impl(smiley, smiley_data, smiley_data_len, filename); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
704 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
705 purple_smiley_data_store(smiley->img); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
706 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
707 return smiley; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
708 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
709 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
710 PurpleSmiley * |
23125
3da84b370eda
Remove undocumented and [apparently] unnecessary parameter from
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22319
diff
changeset
|
711 purple_smiley_new_from_file(const char *shortcut, const char *filepath) |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
712 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
713 PurpleSmiley *smiley = NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
714 guchar *smiley_data; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
715 size_t smiley_data_len; |
23125
3da84b370eda
Remove undocumented and [apparently] unnecessary parameter from
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22319
diff
changeset
|
716 char *filename; |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
717 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
718 g_return_val_if_fail(shortcut != NULL, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
719 g_return_val_if_fail(filepath != NULL, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
720 |
23125
3da84b370eda
Remove undocumented and [apparently] unnecessary parameter from
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22319
diff
changeset
|
721 filename = g_path_get_basename(filepath); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
722 if (read_smiley_file(filepath, &smiley_data, &smiley_data_len)) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
723 smiley = purple_smiley_new_from_stream(shortcut, smiley_data, |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
724 smiley_data_len, filename); |
23125
3da84b370eda
Remove undocumented and [apparently] unnecessary parameter from
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22319
diff
changeset
|
725 g_free(filename); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
726 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
727 return smiley; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
728 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
729 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
730 void |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
731 purple_smiley_delete(PurpleSmiley *smiley) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
732 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
733 g_return_if_fail(smiley != NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
734 |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
735 g_object_unref(smiley); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
736 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
737 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
738 gboolean |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
739 purple_smiley_set_shortcut(PurpleSmiley *smiley, const char *shortcut) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
740 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
741 g_return_val_if_fail(smiley != NULL, FALSE); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
742 g_return_val_if_fail(shortcut != NULL, FALSE); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
743 |
22319
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
744 /* Check out whether the new shortcut is already being used. */ |
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
745 if (g_hash_table_lookup(smiley_shortcut_index, shortcut)) |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
746 return FALSE; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
747 |
22319
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
748 /* Remove the old shortcut. */ |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
749 if (smiley->shortcut) |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
750 g_hash_table_remove(smiley_shortcut_index, smiley->shortcut); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
751 |
22319
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
752 /* Insert the new shortcut. */ |
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
753 g_hash_table_insert(smiley_shortcut_index, g_strdup(shortcut), smiley); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
754 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
755 g_free(smiley->shortcut); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
756 smiley->shortcut = g_strdup(shortcut); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
757 |
23134
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
758 g_object_notify(G_OBJECT(smiley), PROP_SHORTCUT_S); |
6c4f47b9d201
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23125
diff
changeset
|
759 |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
760 purple_smileys_save(); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
761 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
762 return TRUE; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
763 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
764 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
765 void |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
766 purple_smiley_set_data(PurpleSmiley *smiley, guchar *smiley_data, |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
767 size_t smiley_data_len, gboolean keepfilename) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
768 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
769 g_return_if_fail(smiley != NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
770 g_return_if_fail(smiley_data != NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
771 g_return_if_fail(smiley_data_len > 0); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
772 |
22319
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
773 /* Remove the previous entry */ |
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
774 g_hash_table_remove(smiley_checksum_index, smiley->checksum); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
775 |
22319
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
776 /* Update the file data. This also updates the checksum. */ |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
777 if ((keepfilename) && (smiley->img) && |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
778 (purple_imgstore_get_filename(smiley->img))) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
779 purple_smiley_set_data_impl(smiley, smiley_data, |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
780 smiley_data_len, |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
781 purple_imgstore_get_filename(smiley->img)); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
782 else |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
783 purple_smiley_set_data_impl(smiley, smiley_data, |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
784 smiley_data_len, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
785 |
22319
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
786 /* Reinsert the index item. */ |
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
787 g_hash_table_insert(smiley_checksum_index, g_strdup(smiley->checksum), smiley); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
788 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
789 purple_smileys_save(); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
790 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
791 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
792 PurpleStoredImage * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
793 purple_smiley_get_stored_image(const PurpleSmiley *smiley) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
794 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
795 return purple_imgstore_ref(smiley->img); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
796 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
797 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
798 const char *purple_smiley_get_shortcut(const PurpleSmiley *smiley) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
799 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
800 g_return_val_if_fail(smiley != NULL, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
801 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
802 return smiley->shortcut; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
803 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
804 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
805 const char * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
806 purple_smiley_get_checksum(const PurpleSmiley *smiley) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
807 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
808 g_return_val_if_fail(smiley != NULL, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
809 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
810 return smiley->checksum; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
811 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
812 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
813 gconstpointer |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
814 purple_smiley_get_data(const PurpleSmiley *smiley, size_t *len) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
815 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
816 g_return_val_if_fail(smiley != NULL, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
817 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
818 if (smiley->img) { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
819 if (len != NULL) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
820 *len = purple_imgstore_get_size(smiley->img); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
821 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
822 return purple_imgstore_get_data(smiley->img); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
823 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
824 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
825 return NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
826 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
827 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
828 const char * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
829 purple_smiley_get_extension(const PurpleSmiley *smiley) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
830 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
831 if (smiley->img != NULL) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
832 return purple_imgstore_get_extension(smiley->img); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
833 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
834 return NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
835 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
836 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
837 char *purple_smiley_get_full_path(PurpleSmiley *smiley) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
838 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
839 g_return_val_if_fail(smiley != NULL, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
840 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
841 if (smiley->img == NULL) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
842 return NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
843 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
844 return get_file_full_path(purple_imgstore_get_filename(smiley->img)); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
845 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
846 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
847 static void add_smiley_to_list(gpointer key, gpointer value, gpointer user_data) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
848 { |
22318
d1bcb54920f8
Fix a leak, and correct the docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22317
diff
changeset
|
849 GList** returninglist = (GList**)user_data; |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
850 |
22318
d1bcb54920f8
Fix a leak, and correct the docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22317
diff
changeset
|
851 *returninglist = g_list_append(*returninglist, value); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
852 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
853 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
854 GList * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
855 purple_smileys_get_all(void) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
856 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
857 GList *returninglist = NULL; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
858 |
22319
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
859 g_hash_table_foreach(smiley_shortcut_index, add_smiley_to_list, &returninglist); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
860 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
861 return returninglist; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
862 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
863 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
864 PurpleSmiley * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
865 purple_smileys_find_by_shortcut(const char *shortcut) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
866 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
867 g_return_val_if_fail(shortcut != NULL, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
868 |
22319
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
869 return g_hash_table_lookup(smiley_shortcut_index, shortcut); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
870 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
871 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
872 PurpleSmiley * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
873 purple_smileys_find_by_checksum(const char *checksum) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
874 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
875 g_return_val_if_fail(checksum != NULL, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
876 |
22319
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
877 return g_hash_table_lookup(smiley_checksum_index, checksum); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
878 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
879 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
880 const char * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
881 purple_smileys_get_storing_dir(void) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
882 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
883 return smileys_dir; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
884 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
885 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
886 void |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
887 purple_smileys_init() |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
888 { |
22319
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
889 smiley_shortcut_index = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); |
d30bee8d6bdf
Modified patch ('big_smiley_change.patch') from Mauro and Jorge (Masca) to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22318
diff
changeset
|
890 smiley_checksum_index = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
891 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
892 smileys_dir = g_build_filename(purple_user_dir(), SMILEYS_DEFAULT_FOLDER, NULL); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
893 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
894 purple_smileys_load(); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
895 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
896 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
897 void |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
898 purple_smileys_uninit() |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
899 { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
900 if (save_timer != 0) { |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
901 purple_timeout_remove(save_timer); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
902 save_timer = 0; |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
903 sync_smileys(); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
904 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
905 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
906 g_hash_table_destroy(smiley_shortcut_index); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
907 g_hash_table_destroy(smiley_checksum_index); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
908 g_free(smileys_dir); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
909 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
910 |