libpurple/protocols/jabber/caps.c

branch
soc.2008.xmpp
changeset 23599
ac402ffdcbec
parent 23597
ec0bcdfa1da1
child 23600
ca657199f39a
equal deleted inserted replaced
23598:54fe227bf99e 23599:ac402ffdcbec
349 } 349 }
350 g_free(userdata); 350 g_free(userdata);
351 } 351 }
352 } 352 }
353 #endif 353 #endif
354 354 #if 0
355 static void jabber_caps_ext_iqcb(JabberStream *js, xmlnode *packet, gpointer data) { 355 static void jabber_caps_ext_iqcb(JabberStream *js, xmlnode *packet, gpointer data) {
356 /* collect data and fetch all exts */ 356 /* collect data and fetch all exts */
357 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#info"); 357 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#info");
358 jabber_ext_userdata *extuserdata = data; 358 jabber_ext_userdata *extuserdata = data;
359 jabber_caps_cbplususerdata *userdata = extuserdata->userdata; 359 jabber_caps_cbplususerdata *userdata = extuserdata->userdata;
411 411
412 g_free(extuserdata->node); 412 g_free(extuserdata->node);
413 g_free(extuserdata); 413 g_free(extuserdata);
414 jabber_caps_get_info_check_completion(userdata); 414 jabber_caps_get_info_check_completion(userdata);
415 } 415 }
416 416 #endif
417 static void jabber_caps_client_iqcb(JabberStream *js, xmlnode *packet, gpointer data) { 417 static void jabber_caps_client_iqcb(JabberStream *js, xmlnode *packet, gpointer data) {
418 /* collect data and fetch all exts */ 418 /* collect data and fetch all exts */
419 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", 419 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query",
420 "http://jabber.org/protocol/disco#info"); 420 "http://jabber.org/protocol/disco#info");
421 xmlnode *child; 421 xmlnode *child;
422 GList *iter;
423 jabber_caps_cbplususerdata *userdata = data; 422 jabber_caps_cbplususerdata *userdata = data;
424 423
425 /* TODO: Better error checking! */ 424 /* TODO: Better error checking! */
426 if (!strcmp(xmlnode_get_attrib(packet, "type"), "error"))return; 425 if (!strcmp(xmlnode_get_attrib(packet, "type"), "error"))return;
427 if (query) { 426 if (query) {
447 g_free(info); 446 g_free(info);
448 g_free(hash); 447 g_free(hash);
449 printf("\n! ! ! invalid hash ! ! !"); 448 printf("\n! ! ! invalid hash ! ! !");
450 return; 449 return;
451 } 450 }
452 451
453 g_free(hash); 452 g_free(hash);
454 453
455 JabberCapsValue *value = g_new0(JabberCapsValue, 1); 454 JabberCapsValue *value = g_new0(JabberCapsValue, 1);
456 JabberCapsKey *key = g_new0(JabberCapsKey, 1); 455 JabberCapsKey *key = g_new0(JabberCapsKey, 1);
457 #if 0 456 #if 0
458 value->ext = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, jabber_caps_ext_destroy_value); 457 value->ext = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, jabber_caps_ext_destroy_value);
459 #endif 458 #endif
460 key->node = g_strdup(userdata->node); 459 key->node = g_strdup(userdata->node);
461 key->ver = g_strdup(userdata->ver); 460 key->ver = g_strdup(userdata->ver);
462 key->hash = g_strdup(userdata->hash); 461 key->hash = g_strdup(userdata->hash);
462
463 /* check whether it's stil not in the table */
464 if (g_hash_table_lookup(capstable, key)) {
465 jabber_caps_destroy_key(key);
466 g_free(value);
467 return;
468 }
463 469
464 470
465 for(child = query->child; child; child = child->next) { 471 for(child = query->child; child; child = child->next) {
466 if(child->type != XMLNODE_TYPE_TAG) 472 if(child->type != XMLNODE_TYPE_TAG)
467 continue; 473 continue;
526 key->ver = (char *)ver; 532 key->ver = (char *)ver;
527 key->hash = (char*)hash; 533 key->hash = (char*)hash;
528 534
529 client = g_hash_table_lookup(capstable, key); 535 client = g_hash_table_lookup(capstable, key);
530 536
531 //g_free(key);
532
533 g_hash_table_replace(jabber_contact_info, g_strdup(who), key); 537 g_hash_table_replace(jabber_contact_info, g_strdup(who), key);
534 538 g_free(key);
539
535 if(!client) { 540 if(!client) {
536 JabberIq *iq = jabber_iq_new_query(js,JABBER_IQ_GET,"http://jabber.org/protocol/disco#info"); 541 JabberIq *iq = jabber_iq_new_query(js,JABBER_IQ_GET,"http://jabber.org/protocol/disco#info");
537 xmlnode *query = xmlnode_get_child_with_namespace(iq->node,"query","http://jabber.org/protocol/disco#info"); 542 xmlnode *query = xmlnode_get_child_with_namespace(iq->node,"query","http://jabber.org/protocol/disco#info");
538 char *nodever = g_strdup_printf("%s#%s", node, ver); 543 char *nodever = g_strdup_printf("%s#%s", node, ver);
539 xmlnode_set_attrib(query, "node", nodever); 544 xmlnode_set_attrib(query, "node", nodever);
627 formtypefield = xmlnode_get_child(formtypefield, "value"); 632 formtypefield = xmlnode_get_child(formtypefield, "value");
628 return xmlnode_get_data(formtypefield);; 633 return xmlnode_get_data(formtypefield);;
629 } 634 }
630 635
631 static gint jabber_caps_jabber_xdata_compare(gconstpointer a, gconstpointer b) { 636 static gint jabber_caps_jabber_xdata_compare(gconstpointer a, gconstpointer b) {
632 const xmlnode *ac; 637 const xmlnode *aformtypefield = a;
633 const xmlnode *bc; 638 const xmlnode *bformtypefield = b;
634 xmlnode *aformtypefield;
635 xmlnode *bformtypefield;
636 char *aformtype; 639 char *aformtype;
637 char *bformtype; 640 char *bformtype;
638 int result; 641 int result;
639
640 ac = a;
641 bc = b;
642
643 642
644 aformtype = jabber_caps_get_formtype(aformtypefield); 643 aformtype = jabber_caps_get_formtype(aformtypefield);
645 bformtype = jabber_caps_get_formtype(bformtypefield); 644 bformtype = jabber_caps_get_formtype(bformtypefield);
646 645
647 result = strcmp(aformtype, bformtype); 646 result = strcmp(aformtype, bformtype);
696 bc = b; 695 bc = b;
697 696
698 return strcmp(ac->var, bc->var); 697 return strcmp(ac->var, bc->var);
699 } 698 }
700 699
701 GList *jabber_caps_xdata_get_fields(xmlnode *x) { 700 GList *jabber_caps_xdata_get_fields(const xmlnode *x) {
702 GList *fields = 0; 701 GList *fields = 0;
703 xmlnode *field; 702 xmlnode *field;
704 xmlnode *value; 703 xmlnode *value;
705 JabberDataFormField *xdatafield; 704 JabberDataFormField *xdatafield;
706 705
797 context = purple_cipher_context_new_by_name(hash, NULL); 796 context = purple_cipher_context_new_by_name(hash, NULL);
798 if (context == NULL) { 797 if (context == NULL) {
799 //purple_debug_error("jabber", "Could not find cipher\n"); 798 //purple_debug_error("jabber", "Could not find cipher\n");
800 return 0; 799 return 0;
801 } 800 }
802 purple_cipher_context_append(context, verification, strlen(verification)); 801 purple_cipher_context_append(context, (guchar*)verification, strlen(verification));
803 802
804 if (!purple_cipher_context_digest(context, strlen(verification), checksum, &checksum_size)) { 803 if (!purple_cipher_context_digest(context, strlen(verification), checksum, &checksum_size)) {
805 //purple_debug_error("util", "Failed to get digest.\n"); 804 //purple_debug_error("util", "Failed to get digest.\n");
806 } 805 }
807 purple_cipher_context_destroy(context); 806 purple_cipher_context_destroy(context);
817 void jabber_caps_calculate_own_hash(JabberStream *js) { 816 void jabber_caps_calculate_own_hash(JabberStream *js) {
818 JabberCapsClientInfo *info; 817 JabberCapsClientInfo *info;
819 GList *iter = 0; 818 GList *iter = 0;
820 GList *features = 0; 819 GList *features = 0;
821 820
822 /* sort identities */
823 if (jabber_identities == 0 && jabber_features == 0) return; 821 if (jabber_identities == 0 && jabber_features == 0) return;
824 if (jabber_identities) { 822
825 for (iter = jabber_identities; iter; iter = iter->next) {
826 JabberIdentity *ident = iter->data;
827 }
828 }
829
830 /* sort features */ 823 /* sort features */
831 if (jabber_features) { 824 if (jabber_features) {
832 for (iter = jabber_features; iter; iter = iter->next) { 825 for (iter = jabber_features; iter; iter = iter->next) {
833 JabberFeature *feat = iter->data; 826 JabberFeature *feat = iter->data;
834 if(feat->is_enabled == NULL || feat->is_enabled(js, feat->namespace) == TRUE) { 827 if(feat->is_enabled == NULL || feat->is_enabled(js, feat->namespace) == TRUE) {

mercurial