libpurple/protocols/msn/object.c

branch
soc.2010.msn-tlc
changeset 31076
dcc26c5e9d7e
parent 31063
7df334acf090
parent 30580
bb4da51c1259
child 31136
643ef83b4c67
equal deleted inserted replaced
31075:35d41c8c8ed7 31076:dcc26c5e9d7e
94 GET_INT_TAG(type, "Type"); 94 GET_INT_TAG(type, "Type");
95 GET_STRING_TAG(location, "Location"); 95 GET_STRING_TAG(location, "Location");
96 GET_STRING_TAG(friendly, "Friendly"); 96 GET_STRING_TAG(friendly, "Friendly");
97 GET_STRING_TAG(sha1d, "SHA1D"); 97 GET_STRING_TAG(sha1d, "SHA1D");
98 GET_STRING_TAG(sha1c, "SHA1C"); 98 GET_STRING_TAG(sha1c, "SHA1C");
99 GET_STRING_TAG(url, "Url");
100 GET_STRING_TAG(url1, "Url1");
99 101
100 /* If we are missing any of the required elements then discard the object */ 102 /* If we are missing any of the required elements then discard the object */
101 /* SHA1C is not always sent anymore */
102 if (obj->creator == NULL || obj->size == 0 || obj->type == 0 103 if (obj->creator == NULL || obj->size == 0 || obj->type == 0
103 || obj->location == NULL || obj->friendly == NULL 104 || obj->sha1d == NULL) {
104 || obj->sha1d == NULL /*|| obj->sha1c == NULL*/) {
105 purple_debug_error("msn", "Discarding invalid msnobj: '%s'\n", str); 105 purple_debug_error("msn", "Discarding invalid msnobj: '%s'\n", str);
106 msn_object_destroy(obj); 106 msn_object_destroy(obj);
107 obj = NULL; 107 return NULL;
108 }
109
110 if (obj->location == NULL || obj->friendly == NULL) {
111 /* Location/friendly are required for non-buddyicon objects */
112 if (obj->type != MSN_OBJECT_USERTILE) {
113 purple_debug_error("msn", "Discarding invalid msnobj: '%s'\n", str);
114 msn_object_destroy(obj);
115 return NULL;
116 /* Buddy icon object can contain Url/Url1 instead */
117 } else if (obj->url == NULL || obj->url1 == NULL) {
118 purple_debug_error("msn", "Discarding invalid msnobj: '%s'\n", str);
119 msn_object_destroy(obj);
120 return NULL;
121 }
108 } 122 }
109 123
110 return obj; 124 return obj;
111 } 125 }
112 126
282 296
283 g_free(obj->sha1c); 297 g_free(obj->sha1c);
284 obj->sha1c = g_strdup(sha1c); 298 obj->sha1c = g_strdup(sha1c);
285 } 299 }
286 300
301 void
302 msn_object_set_url(MsnObject *obj, const char *url)
303 {
304 g_return_if_fail(obj != NULL);
305
306 g_free(obj->url);
307 obj->url = g_strdup(url);
308 }
309
310 void
311 msn_object_set_url1(MsnObject *obj, const char *url)
312 {
313 g_return_if_fail(obj != NULL);
314
315 g_free(obj->url1);
316 obj->url1 = g_strdup(url);
317 }
318
287 const char * 319 const char *
288 msn_object_get_creator(const MsnObject *obj) 320 msn_object_get_creator(const MsnObject *obj)
289 { 321 {
290 g_return_val_if_fail(obj != NULL, NULL); 322 g_return_val_if_fail(obj != NULL, NULL);
291 323
350 } else { 382 } else {
351 return obj->sha1d; 383 return obj->sha1d;
352 } 384 }
353 } 385 }
354 386
387 const char *
388 msn_object_get_url(const MsnObject *obj)
389 {
390 g_return_val_if_fail(obj != NULL, NULL);
391
392 return obj->url;
393 }
394
395 const char *
396 msn_object_get_url1(const MsnObject *obj)
397 {
398 g_return_val_if_fail(obj != NULL, NULL);
399
400 return obj->url1;
401 }
402
355 MsnObject * 403 MsnObject *
356 msn_object_find_local(const char *sha1) 404 msn_object_find_local(const char *sha1)
357 { 405 {
358 GList *l; 406 GList *l;
359 407

mercurial