Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/caps.c @ 25753:b6cfc5cc6799
Whitespace cleanup (no functional changes, just unwrap the huge if block and
remove the #if 0'd code
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Fri, 21 Nov 2008 20:30:21 +0000 |
parents | c2438ad6e6c1 |
children | ec0c95ae4a65 |
comparison
equal
deleted
inserted
replaced
25752:c2438ad6e6c1 | 25753:b6cfc5cc6799 |
---|---|
431 static void jabber_caps_client_iqcb(JabberStream *js, xmlnode *packet, gpointer data) { | 431 static void jabber_caps_client_iqcb(JabberStream *js, xmlnode *packet, gpointer data) { |
432 /* collect data and fetch all exts */ | 432 /* collect data and fetch all exts */ |
433 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", | 433 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", |
434 "http://jabber.org/protocol/disco#info"); | 434 "http://jabber.org/protocol/disco#info"); |
435 jabber_caps_cbplususerdata *userdata = data; | 435 jabber_caps_cbplususerdata *userdata = data; |
436 JabberCapsClientInfo *info; | |
437 gchar *hash; | |
438 JabberCapsValue *value; | |
439 JabberCapsKey *key; | |
440 xmlnode *child; | |
436 | 441 |
437 /* TODO: Better error checking! */ | 442 /* TODO: Better error checking! */ |
438 if (!strcmp(xmlnode_get_attrib(packet, "type"), "error"))return; | 443 if (!query || !strcmp(xmlnode_get_attrib(packet, "type"), "error")) |
439 if (query) { | 444 return; |
440 /* check hash */ | 445 |
441 JabberCapsClientInfo *info = jabber_caps_parse_client_info(query); | 446 /* check hash */ |
442 gchar *hash = 0; | 447 info = jabber_caps_parse_client_info(query); |
443 JabberCapsValue *value; | 448 |
444 JabberCapsKey *key; | 449 if (!strcmp(userdata->hash, "sha-1")) { |
445 xmlnode *child; | 450 hash = jabber_caps_calculate_hash(info, "sha1"); |
446 | 451 } else if (!strcmp(userdata->hash, "md5")) { |
447 if (!strcmp(userdata->hash, "sha-1")) { | 452 hash = jabber_caps_calculate_hash(info, "md5"); |
448 hash = jabber_caps_calculate_hash(info, "sha1"); | 453 } else { |
449 } else if (!strcmp(userdata->hash, "md5")) { | 454 /* TODO: clean up */ |
450 hash = jabber_caps_calculate_hash(info, "md5"); | 455 return; |
451 } else { | 456 } |
452 /* TODO: clean up */ | 457 |
453 return; | 458 printf("\n\tfrom: %s", xmlnode_get_attrib(packet, "from")); |
454 } | 459 printf("\n\tnode: %s", xmlnode_get_attrib(query, "node")); |
455 | 460 printf("\n\tcalculated key: %s", hash); |
456 printf("\n\tfrom: %s", xmlnode_get_attrib(packet, "from")); | 461 printf("\n\thash: %s", userdata->hash); |
457 printf("\n\tnode: %s", xmlnode_get_attrib(query, "node")); | 462 printf("\n"); |
458 printf("\n\tcalculated key: %s", hash); | 463 |
459 printf("\n\thash: %s", userdata->hash); | 464 if (strcmp(hash, userdata->ver)) { |
460 printf("\n"); | 465 g_free(info); |
461 | |
462 if (strcmp(hash, userdata->ver)) { | |
463 g_free(info); | |
464 g_free(hash); | |
465 printf("\n! ! ! invalid hash ! ! !"); | |
466 return; | |
467 } | |
468 | |
469 g_free(hash); | 466 g_free(hash); |
470 | 467 printf("\n! ! ! invalid hash ! ! !"); |
471 value = g_new0(JabberCapsValue, 1); | 468 return; |
472 key = g_new0(JabberCapsKey, 1); | 469 } |
473 | 470 |
474 #if 0 | 471 g_free(hash); |
475 value->ext = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, jabber_caps_ext_destroy_value); | 472 |
476 #endif | 473 value = g_new0(JabberCapsValue, 1); |
477 key->node = g_strdup(userdata->node); | 474 key = g_new0(JabberCapsKey, 1); |
478 key->ver = g_strdup(userdata->ver); | 475 |
479 key->hash = g_strdup(userdata->hash); | 476 #if 0 |
480 | 477 value->ext = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, jabber_caps_ext_destroy_value); |
481 /* check whether it's stil not in the table */ | 478 #endif |
482 if (g_hash_table_lookup(capstable, key)) { | 479 key->node = g_strdup(userdata->node); |
483 jabber_caps_destroy_key(key); | 480 key->ver = g_strdup(userdata->ver); |
484 g_free(value); | 481 key->hash = g_strdup(userdata->hash); |
485 return; | 482 |
486 } | 483 /* check whether it's stil not in the table */ |
487 | 484 if (g_hash_table_lookup(capstable, key)) { |
488 | 485 jabber_caps_destroy_key(key); |
489 for(child = query->child; child; child = child->next) { | 486 g_free(value); |
490 if(child->type != XMLNODE_TYPE_TAG) | 487 return; |
488 } | |
489 | |
490 | |
491 for(child = query->child; child; child = child->next) { | |
492 if(child->type != XMLNODE_TYPE_TAG) | |
493 continue; | |
494 if(!strcmp(child->name,"feature")) { | |
495 const char *var = xmlnode_get_attrib(child, "var"); | |
496 if(!var) | |
491 continue; | 497 continue; |
492 if(!strcmp(child->name,"feature")) { | 498 value->features = g_list_append(value->features, g_strdup(var)); |
493 const char *var = xmlnode_get_attrib(child, "var"); | 499 } else if(!strcmp(child->name,"identity")) { |
494 if(!var) | 500 const char *category = xmlnode_get_attrib(child, "category"); |
495 continue; | 501 const char *type = xmlnode_get_attrib(child, "type"); |
496 value->features = g_list_append(value->features, g_strdup(var)); | 502 const char *name = xmlnode_get_attrib(child, "name"); |
497 } else if(!strcmp(child->name,"identity")) { | 503 const char *lang = xmlnode_get_attrib(child, "lang"); |
498 const char *category = xmlnode_get_attrib(child, "category"); | 504 |
499 const char *type = xmlnode_get_attrib(child, "type"); | 505 JabberIdentity *id = g_new0(JabberIdentity, 1); |
500 const char *name = xmlnode_get_attrib(child, "name"); | 506 id->category = g_strdup(category); |
501 const char *lang = xmlnode_get_attrib(child, "lang"); | 507 id->type = g_strdup(type); |
502 | 508 id->name = g_strdup(name); |
503 JabberIdentity *id = g_new0(JabberIdentity, 1); | 509 id->lang = g_strdup(lang); |
504 id->category = g_strdup(category); | 510 |
505 id->type = g_strdup(type); | 511 value->identities = g_list_append(value->identities,id); |
506 id->name = g_strdup(name); | 512 } else if(!strcmp(child->name, "x")) { |
507 id->lang = g_strdup(lang); | 513 value->forms = g_list_append(value->forms, xmlnode_copy(child)); |
508 | 514 } |
509 value->identities = g_list_append(value->identities,id); | 515 } |
510 } else if(!strcmp(child->name, "x")) { | 516 |
511 value->forms = g_list_append(value->forms, xmlnode_copy(child)); | 517 g_hash_table_replace(capstable, key, value); |
512 } | 518 jabber_caps_store(); |
513 } | |
514 | |
515 g_hash_table_replace(capstable, key, value); | |
516 jabber_caps_store(); | |
517 | |
518 | |
519 #if 0 | |
520 /* fetch all exts */ | |
521 for(iter = userdata->ext; iter; iter = g_list_next(iter)) { | |
522 JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_GET, | |
523 "http://jabber.org/protocol/disco#info"); | |
524 xmlnode *query = xmlnode_get_child_with_namespace(iq->node, | |
525 "query", "http://jabber.org/protocol/disco#info"); | |
526 char *node = g_strdup_printf("%s#%s", userdata->node, (const char*)iter->data); | |
527 jabber_ext_userdata *ext_data = g_new0(jabber_ext_userdata, 1); | |
528 ext_data->node = node; | |
529 ext_data->userdata = userdata; | |
530 | |
531 xmlnode_set_attrib(query, "node", node); | |
532 xmlnode_set_attrib(iq->node, "to", userdata->who); | |
533 | |
534 jabber_iq_set_callback(iq, jabber_caps_ext_iqcb, ext_data); | |
535 jabber_iq_send(iq); | |
536 } | |
537 | |
538 } else | |
539 /* Don't wait for the ext discoveries; they aren't going to happen */ | |
540 userdata->extOutstanding = 0; | |
541 | |
542 jabber_caps_get_info_check_completion(userdata); | |
543 #endif | |
544 } | |
545 } | 519 } |
546 | 520 |
547 void jabber_caps_get_info(JabberStream *js, const char *who, const char *node, | 521 void jabber_caps_get_info(JabberStream *js, const char *who, const char *node, |
548 const char *ver, const char *hash, jabber_caps_get_info_cb cb, | 522 const char *ver, const char *hash, jabber_caps_get_info_cb cb, |
549 gpointer user_data) | 523 gpointer user_data) |