libpurple/smiley.c

Thu, 06 Feb 2014 17:25:40 +0530

author
Ankit Vani <a@nevitus.org>
date
Thu, 06 Feb 2014 17:25:40 +0530
branch
gtkdoc-conversion
changeset 35470
8ee08a41f2f3
parent 35454
cf2a24d01503
child 35698
302a7cb4c1ab
child 37075
cf3f735b09b7
permissions
-rw-r--r--

Convert some other doxygen-type comments

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

mercurial