libpurple/protocols/msn/object.c

Mon, 12 Sep 2016 08:55:35 -0500

author
Mike Ruprecht <cmaiku@gmail.com>
date
Mon, 12 Sep 2016 08:55:35 -0500
changeset 38142
1dff6e343f9f
parent 37426
6fd4989b77e4
child 38298
f0a8f63f9312
child 38328
722f62a4b0c2
permissions
-rw-r--r--

gg: Protect against issues when closing while connecting

Since the GIOStream is cancelled when data is freed, any cancelled
callbacks are called after such data is freed. This patch guards against
cancelled calls by safely returning without accessing any freed data if
the connection has been cancelled (aka closed).

Futhermore, if GG tries to connect and is quickly disconnected,
ggp_tcpsocket_close() is never called. As far as I can tell, it's an
existing bug, but PurpleSockets both work differently when closing and
are closed by the connection if any leak. So the issue wasn't a major
problem. This patch lessens the issue by guarding against it, but it
should be fixed at some point.

9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
1 /**
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
2 * @file object.c MSNObject API
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
3 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15870
diff changeset
4 * purple
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
5 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15870
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
9198
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
8 * source distribution.
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
9 *
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
13 * (at your option) any later version.
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
14 *
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
19 *
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16538
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
23 */
28981
4e3922ab4844 Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <darkrain42@pidgin.im>
parents: 23441
diff changeset
24
4e3922ab4844 Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <darkrain42@pidgin.im>
parents: 23441
diff changeset
25 #include "msn.h"
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
26 #include "object.h"
15049
d8749c39e1e4 [gaim-migrate @ 17766]
Daniel Atallah <datallah@pidgin.im>
parents: 14419
diff changeset
27 #include "debug.h"
22653
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
28 /* Sha1 stuff */
34567
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34557
diff changeset
29 #include "ciphers/sha1hash.h"
22653
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
30 /* Base64 stuff */
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
31 #include "util.h"
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
32
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
33 #define GET_STRING_TAG(field, id) \
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
34 if ((tag = strstr(str, id "=\"")) != NULL) \
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
35 { \
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
36 tag += strlen(id "=\""); \
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
37 c = strchr(tag, '"'); \
10116
054b064145a1 [gaim-migrate @ 11153]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10093
diff changeset
38 if (c != NULL) \
054b064145a1 [gaim-migrate @ 11153]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10093
diff changeset
39 { \
37426
6fd4989b77e4 The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents: 35827
diff changeset
40 g_free(obj->field); \
10116
054b064145a1 [gaim-migrate @ 11153]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10093
diff changeset
41 obj->field = g_strndup(tag, c - tag); \
054b064145a1 [gaim-migrate @ 11153]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10093
diff changeset
42 } \
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
43 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
44
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
45 #define GET_INT_TAG(field, id) \
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
46 if ((tag = strstr(str, id "=\"")) != NULL) \
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
47 { \
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
48 char buf[16]; \
9823
676d416efa7e [gaim-migrate @ 10694]
Mark Doliner <markdoliner@pidgin.im>
parents: 9776
diff changeset
49 size_t offset; \
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
50 tag += strlen(id "=\""); \
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
51 c = strchr(tag, '"'); \
9823
676d416efa7e [gaim-migrate @ 10694]
Mark Doliner <markdoliner@pidgin.im>
parents: 9776
diff changeset
52 if (c != NULL) \
676d416efa7e [gaim-migrate @ 10694]
Mark Doliner <markdoliner@pidgin.im>
parents: 9776
diff changeset
53 { \
676d416efa7e [gaim-migrate @ 10694]
Mark Doliner <markdoliner@pidgin.im>
parents: 9776
diff changeset
54 memset(buf, 0, sizeof(buf)); \
676d416efa7e [gaim-migrate @ 10694]
Mark Doliner <markdoliner@pidgin.im>
parents: 9776
diff changeset
55 offset = c - tag; \
676d416efa7e [gaim-migrate @ 10694]
Mark Doliner <markdoliner@pidgin.im>
parents: 9776
diff changeset
56 if (offset >= sizeof(buf)) \
676d416efa7e [gaim-migrate @ 10694]
Mark Doliner <markdoliner@pidgin.im>
parents: 9776
diff changeset
57 offset = sizeof(buf) - 1; \
676d416efa7e [gaim-migrate @ 10694]
Mark Doliner <markdoliner@pidgin.im>
parents: 9776
diff changeset
58 strncpy(buf, tag, offset); \
676d416efa7e [gaim-migrate @ 10694]
Mark Doliner <markdoliner@pidgin.im>
parents: 9776
diff changeset
59 obj->field = atoi(buf); \
676d416efa7e [gaim-migrate @ 10694]
Mark Doliner <markdoliner@pidgin.im>
parents: 9776
diff changeset
60 } \
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
61 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
62
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
63 static GList *local_objs;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
64
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
65 MsnObject *
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
66 msn_object_new(void)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
67 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
68 MsnObject *obj;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
69
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
70 obj = g_new0(MsnObject, 1);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
71
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
72 msn_object_set_type(obj, MSN_OBJECT_UNKNOWN);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
73 msn_object_set_friendly(obj, "AAA=");
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
74
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
75 return obj;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
76 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
77
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
78 MsnObject *
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
79 msn_object_new_from_string(const char *str)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
80 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
81 MsnObject *obj;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
82 char *tag, *c;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
83
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
84 g_return_val_if_fail(str != NULL, NULL);
14419
b2710bc260e8 [gaim-migrate @ 17063]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
85
b2710bc260e8 [gaim-migrate @ 17063]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
86 if (strncmp(str, "<msnobj ", 8))
b2710bc260e8 [gaim-migrate @ 17063]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
87 return NULL;
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
88
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
89 obj = msn_object_new();
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
90
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
91 GET_STRING_TAG(creator, "Creator");
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
92 GET_INT_TAG(size, "Size");
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
93 GET_INT_TAG(type, "Type");
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
94 GET_STRING_TAG(location, "Location");
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
95 GET_STRING_TAG(friendly, "Friendly");
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
96 GET_STRING_TAG(sha1d, "SHA1D");
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
97 GET_STRING_TAG(sha1c, "SHA1C");
30580
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
98 GET_STRING_TAG(url, "Url");
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
99 GET_STRING_TAG(url1, "Url1");
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
100
9776
18190cb3c009 [gaim-migrate @ 10644]
Daniel Atallah <datallah@pidgin.im>
parents: 9198
diff changeset
101 /* If we are missing any of the required elements then discard the object */
18190cb3c009 [gaim-migrate @ 10644]
Daniel Atallah <datallah@pidgin.im>
parents: 9198
diff changeset
102 if (obj->creator == NULL || obj->size == 0 || obj->type == 0
30580
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
103 || obj->sha1d == NULL) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15870
diff changeset
104 purple_debug_error("msn", "Discarding invalid msnobj: '%s'\n", str);
32312
44c2bc252f60 Be a bit more specific about removing non-local MSN objects, which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31136
diff changeset
105 msn_object_destroy(obj, FALSE);
30580
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
106 return NULL;
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
107 }
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
108
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
109 if (obj->location == NULL || obj->friendly == NULL) {
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
110 /* Location/friendly are required for non-buddyicon objects */
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
111 if (obj->type != MSN_OBJECT_USERTILE) {
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
112 purple_debug_error("msn", "Discarding invalid msnobj: '%s'\n", str);
32312
44c2bc252f60 Be a bit more specific about removing non-local MSN objects, which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31136
diff changeset
113 msn_object_destroy(obj, FALSE);
30580
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
114 return NULL;
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
115 /* Buddy icon object can contain Url/Url1 instead */
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
116 } else if (obj->url == NULL || obj->url1 == NULL) {
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
117 purple_debug_error("msn", "Discarding invalid msnobj: '%s'\n", str);
32312
44c2bc252f60 Be a bit more specific about removing non-local MSN objects, which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31136
diff changeset
118 msn_object_destroy(obj, FALSE);
30580
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
119 return NULL;
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
120 }
9776
18190cb3c009 [gaim-migrate @ 10644]
Daniel Atallah <datallah@pidgin.im>
parents: 9198
diff changeset
121 }
18190cb3c009 [gaim-migrate @ 10644]
Daniel Atallah <datallah@pidgin.im>
parents: 9198
diff changeset
122
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
123 return obj;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
124 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
125
22653
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
126 MsnObject*
35827
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34567
diff changeset
127 msn_object_new_from_image(PurpleImage *img, const char *location,
22653
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
128 const char *creator, MsnObjectType type)
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
129 {
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
130 MsnObject *msnobj;
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
131
34567
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34557
diff changeset
132 PurpleHash *hash;
22653
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
133 char *buf;
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
134 gconstpointer data;
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
135 size_t size;
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
136 char *base64;
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
137 unsigned char digest[20];
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
138
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
139 msnobj = NULL;
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
140
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
141 if (img == NULL)
35827
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34567
diff changeset
142 return NULL;
22653
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
143
35827
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34567
diff changeset
144 size = purple_image_get_size(img);
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34567
diff changeset
145 data = purple_image_get_data(img);
22653
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
146
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
147 /* New object */
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
148 msnobj = msn_object_new();
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
149 msn_object_set_local(msnobj);
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
150 msn_object_set_type(msnobj, type);
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
151 msn_object_set_location(msnobj, location);
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
152 msn_object_set_creator(msnobj, creator);
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
153
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
154 msn_object_set_image(msnobj, img);
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
155
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
156 /* Compute the SHA1D field. */
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
157 memset(digest, 0, sizeof(digest));
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
158
34567
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34557
diff changeset
159 hash = purple_sha1_hash_new();
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34557
diff changeset
160 purple_hash_append(hash, data, size);
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34557
diff changeset
161 purple_hash_digest(hash, digest, sizeof(digest));
22653
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
162
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
163 base64 = purple_base64_encode(digest, sizeof(digest));
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
164 msn_object_set_sha1d(msnobj, base64);
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
165 g_free(base64);
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
166
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
167 msn_object_set_size(msnobj, size);
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
168
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
169 /* Compute the SHA1C field. */
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
170 buf = g_strdup_printf(
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
171 "Creator%sSize%dType%dLocation%sFriendly%sSHA1D%s",
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
172 msn_object_get_creator(msnobj),
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
173 msn_object_get_size(msnobj),
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
174 msn_object_get_type(msnobj),
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
175 msn_object_get_location(msnobj),
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
176 msn_object_get_friendly(msnobj),
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
177 msn_object_get_sha1d(msnobj));
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
178
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
179 memset(digest, 0, sizeof(digest));
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
180
34567
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34557
diff changeset
181 purple_hash_reset(hash);
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34557
diff changeset
182 purple_hash_append(hash, (const guchar *)buf, strlen(buf));
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34557
diff changeset
183 purple_hash_digest(hash, digest, sizeof(digest));
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34557
diff changeset
184 g_object_unref(hash);
22653
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
185 g_free(buf);
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
186
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
187 base64 = purple_base64_encode(digest, sizeof(digest));
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
188 msn_object_set_sha1c(msnobj, base64);
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
189 g_free(base64);
23441
fd45c23a3eb2 Delete trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 22653
diff changeset
190
22653
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
191 return msnobj;
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
192 }
bed3d8152a58 The patch to msn to allow sending custom smileys. Doesn't send all the custom smileys correctly at the moment. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21067
diff changeset
193
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
194 void
32312
44c2bc252f60 Be a bit more specific about removing non-local MSN objects, which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31136
diff changeset
195 msn_object_destroy(MsnObject *obj, gboolean only_remote)
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
196 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
197 g_return_if_fail(obj != NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
198
32312
44c2bc252f60 Be a bit more specific about removing non-local MSN objects, which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31136
diff changeset
199 if (only_remote && obj->local)
44c2bc252f60 Be a bit more specific about removing non-local MSN objects, which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31136
diff changeset
200 return;
44c2bc252f60 Be a bit more specific about removing non-local MSN objects, which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31136
diff changeset
201
15049
d8749c39e1e4 [gaim-migrate @ 17766]
Daniel Atallah <datallah@pidgin.im>
parents: 14419
diff changeset
202 g_free(obj->creator);
d8749c39e1e4 [gaim-migrate @ 17766]
Daniel Atallah <datallah@pidgin.im>
parents: 14419
diff changeset
203 g_free(obj->location);
d8749c39e1e4 [gaim-migrate @ 17766]
Daniel Atallah <datallah@pidgin.im>
parents: 14419
diff changeset
204 g_free(obj->friendly);
d8749c39e1e4 [gaim-migrate @ 17766]
Daniel Atallah <datallah@pidgin.im>
parents: 14419
diff changeset
205 g_free(obj->sha1d);
d8749c39e1e4 [gaim-migrate @ 17766]
Daniel Atallah <datallah@pidgin.im>
parents: 14419
diff changeset
206 g_free(obj->sha1c);
31136
643ef83b4c67 Fix a lot more leaks, some old, some new.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31076
diff changeset
207 g_free(obj->url);
643ef83b4c67 Fix a lot more leaks, some old, some new.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31076
diff changeset
208 g_free(obj->url1);
9198
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
209
35827
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34567
diff changeset
210 if (obj->img)
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34567
diff changeset
211 g_object_unref(obj->img);
16538
c7e61e2917c9 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents: 16090
diff changeset
212
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
213 if (obj->local)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
214 local_objs = g_list_remove(local_objs, obj);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
215
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
216 g_free(obj);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
217 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
218
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
219 char *
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
220 msn_object_to_string(const MsnObject *obj)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
221 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
222 char *str;
15870
845136ee546d Protection against missing SHA1C
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15435
diff changeset
223 const char *sha1c;
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
224
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
225 g_return_val_if_fail(obj != NULL, NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
226
15870
845136ee546d Protection against missing SHA1C
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15435
diff changeset
227 sha1c = msn_object_get_sha1c(obj);
845136ee546d Protection against missing SHA1C
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15435
diff changeset
228
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
229 str = g_strdup_printf("<msnobj Creator=\"%s\" Size=\"%d\" Type=\"%d\" "
15870
845136ee546d Protection against missing SHA1C
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15435
diff changeset
230 "Location=\"%s\" Friendly=\"%s\" SHA1D=\"%s\""
845136ee546d Protection against missing SHA1C
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15435
diff changeset
231 "%s%s%s/>",
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
232 msn_object_get_creator(obj),
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
233 msn_object_get_size(obj),
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
234 msn_object_get_type(obj),
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
235 msn_object_get_location(obj),
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
236 msn_object_get_friendly(obj),
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
237 msn_object_get_sha1d(obj),
15870
845136ee546d Protection against missing SHA1C
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15435
diff changeset
238 sha1c ? " SHA1C=\"" : "",
845136ee546d Protection against missing SHA1C
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15435
diff changeset
239 sha1c ? sha1c : "",
845136ee546d Protection against missing SHA1C
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15435
diff changeset
240 sha1c ? "\"" : "");
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
241
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
242 return str;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
243 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
244
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
245 void
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
246 msn_object_set_creator(MsnObject *obj, const char *creator)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
247 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
248 g_return_if_fail(obj != NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
249
21067
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
250 g_free(obj->creator);
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
251 obj->creator = g_strdup(creator);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
252 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
253
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
254 void
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
255 msn_object_set_size(MsnObject *obj, int size)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
256 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
257 g_return_if_fail(obj != NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
258
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
259 obj->size = size;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
260 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
261
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
262 void
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
263 msn_object_set_type(MsnObject *obj, MsnObjectType type)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
264 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
265 g_return_if_fail(obj != NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
266
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
267 obj->type = type;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
268 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
269
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
270 void
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
271 msn_object_set_location(MsnObject *obj, const char *location)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
272 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
273 g_return_if_fail(obj != NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
274
21067
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
275 g_free(obj->location);
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
276 obj->location = g_strdup(location);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
277 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
278
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
279 void
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
280 msn_object_set_friendly(MsnObject *obj, const char *friendly)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
281 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
282 g_return_if_fail(obj != NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
283
21067
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
284 g_free(obj->friendly);
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
285 obj->friendly = g_strdup(friendly);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
286 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
287
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
288 void
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
289 msn_object_set_sha1d(MsnObject *obj, const char *sha1d)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
290 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
291 g_return_if_fail(obj != NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
292
21067
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
293 g_free(obj->sha1d);
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
294 obj->sha1d = g_strdup(sha1d);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
295 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
296
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
297 void
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
298 msn_object_set_sha1c(MsnObject *obj, const char *sha1c)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
299 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
300 g_return_if_fail(obj != NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
301
21067
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
302 g_free(obj->sha1c);
97a745428ab0 Cleanup some unnecessary NULL checks in g_strdup()/g_free().
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
303 obj->sha1c = g_strdup(sha1c);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
304 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
305
30580
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
306 void
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
307 msn_object_set_url(MsnObject *obj, const char *url)
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
308 {
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
309 g_return_if_fail(obj != NULL);
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
310
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
311 g_free(obj->url);
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
312 obj->url = g_strdup(url);
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
313 }
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
314
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
315 void
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
316 msn_object_set_url1(MsnObject *obj, const char *url)
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
317 {
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
318 g_return_if_fail(obj != NULL);
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
319
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
320 g_free(obj->url1);
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
321 obj->url1 = g_strdup(url);
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
322 }
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
323
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
324 const char *
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
325 msn_object_get_creator(const MsnObject *obj)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
326 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
327 g_return_val_if_fail(obj != NULL, NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
328
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
329 return obj->creator;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
330 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
331
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
332 int
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
333 msn_object_get_size(const MsnObject *obj)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
334 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
335 g_return_val_if_fail(obj != NULL, 0);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
336
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
337 return obj->size;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
338 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
339
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
340 MsnObjectType
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
341 msn_object_get_type(const MsnObject *obj)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
342 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
343 g_return_val_if_fail(obj != NULL, MSN_OBJECT_UNKNOWN);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
344
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
345 return obj->type;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
346 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
347
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
348 const char *
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
349 msn_object_get_location(const MsnObject *obj)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
350 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
351 g_return_val_if_fail(obj != NULL, NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
352
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
353 return obj->location;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
354 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
355
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
356 const char *
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
357 msn_object_get_friendly(const MsnObject *obj)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
358 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
359 g_return_val_if_fail(obj != NULL, NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
360
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
361 return obj->friendly;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
362 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
363
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
364 const char *
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
365 msn_object_get_sha1d(const MsnObject *obj)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
366 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
367 g_return_val_if_fail(obj != NULL, NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
368
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
369 return obj->sha1d;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
370 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
371
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
372 const char *
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
373 msn_object_get_sha1c(const MsnObject *obj)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
374 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
375 g_return_val_if_fail(obj != NULL, NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
376
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
377 return obj->sha1c;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
378 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
379
16090
57832613774a Patch in Trac ticket #113 from Simom.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
380 const char *
57832613774a Patch in Trac ticket #113 from Simom.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
381 msn_object_get_sha1(const MsnObject *obj)
57832613774a Patch in Trac ticket #113 from Simom.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
382 {
57832613774a Patch in Trac ticket #113 from Simom.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
383 g_return_val_if_fail(obj != NULL, NULL);
57832613774a Patch in Trac ticket #113 from Simom.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
384
57832613774a Patch in Trac ticket #113 from Simom.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
385 if(obj->sha1c != NULL) {
57832613774a Patch in Trac ticket #113 from Simom.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
386 return obj->sha1c;
57832613774a Patch in Trac ticket #113 from Simom.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
387 } else {
57832613774a Patch in Trac ticket #113 from Simom.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
388 return obj->sha1d;
57832613774a Patch in Trac ticket #113 from Simom.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
389 }
57832613774a Patch in Trac ticket #113 from Simom.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
390 }
57832613774a Patch in Trac ticket #113 from Simom.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
391
30580
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
392 const char *
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
393 msn_object_get_url(const MsnObject *obj)
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
394 {
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
395 g_return_val_if_fail(obj != NULL, NULL);
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
396
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
397 return obj->url;
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
398 }
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
399
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
400 const char *
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
401 msn_object_get_url1(const MsnObject *obj)
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
402 {
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
403 g_return_val_if_fail(obj != NULL, NULL);
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
404
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
405 return obj->url1;
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
406 }
bb4da51c1259 Add support for Url/Url1 in MSN objects, which are used for buddy
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 28981
diff changeset
407
31063
7df334acf090 Don't destroy our local object storing the display picture when a NLN command show us the same MsnObject.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 28981
diff changeset
408 MsnObject *
16090
57832613774a Patch in Trac ticket #113 from Simom.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
409 msn_object_find_local(const char *sha1)
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
410 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
411 GList *l;
9198
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
412
16090
57832613774a Patch in Trac ticket #113 from Simom.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
413 g_return_val_if_fail(sha1 != NULL, NULL);
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
414
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
415 for (l = local_objs; l != NULL; l = l->next)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
416 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
417 MsnObject *local_obj = l->data;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
418
16090
57832613774a Patch in Trac ticket #113 from Simom.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
419 if (!strcmp(msn_object_get_sha1(local_obj), sha1))
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
420 return local_obj;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
421 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
422
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
423 return NULL;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
424
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
425 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
426
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
427 void
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
428 msn_object_set_local(MsnObject *obj)
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
429 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
430 g_return_if_fail(obj != NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
431
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
432 obj->local = TRUE;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
433
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
434 local_objs = g_list_append(local_objs, obj);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
435 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
436
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
437 void
35827
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34567
diff changeset
438 msn_object_set_image(MsnObject *obj, PurpleImage *img)
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
439 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
440 g_return_if_fail(obj != NULL);
16538
c7e61e2917c9 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents: 16090
diff changeset
441 g_return_if_fail(img != NULL);
9198
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
442
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
443 /* obj->local = TRUE; */
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
444
35827
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34567
diff changeset
445 if (obj->img)
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34567
diff changeset
446 g_object_unref(obj->img);
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34567
diff changeset
447 g_object_ref(img);
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34567
diff changeset
448 obj->img = img;
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
449 }
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
450
35827
c7c855c36c9b imgstore: unref msn
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34567
diff changeset
451 PurpleImage *
16538
c7e61e2917c9 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents: 16090
diff changeset
452 msn_object_get_image(const MsnObject *obj)
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
453 {
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
454 MsnObject *local_obj;
9198
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
455
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
456 g_return_val_if_fail(obj != NULL, NULL);
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
457
16090
57832613774a Patch in Trac ticket #113 from Simom.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
458 local_obj = msn_object_find_local(msn_object_get_sha1(obj));
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
459
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
460 if (local_obj != NULL)
16538
c7e61e2917c9 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents: 16090
diff changeset
461 return local_obj->img;
9198
e8eb6d5eb9eb [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
462
9193
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
463 return NULL;
6e76f1367896 [gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
diff changeset
464 }

mercurial