Changes in protocols/jabber/iq.c [a73e91a:4358b10]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/iq.c
ra73e91a r4358b10 90 90 pack = 0; 91 91 } 92 else if( strcmp( s, XMLNS_DISCO VER) == 0 )93 { 94 const char *features[] = { XMLNS_DISCO VER,92 else if( strcmp( s, XMLNS_DISCO_INFO ) == 0 ) 93 { 94 const char *features[] = { XMLNS_DISCO_INFO, 95 95 XMLNS_VERSION, 96 96 XMLNS_TIME, … … 98 98 XMLNS_MUC, 99 99 XMLNS_PING, 100 XMLNS_SI, 101 XMLNS_BYTESTREAMS, 102 XMLNS_FILETRANSFER, 100 103 NULL }; 101 104 const char **f; … … 117 120 { 118 121 xt_free_node( reply ); 119 reply = jabber_make_error_packet( node, "feature-not-implemented", "cancel" );122 reply = jabber_make_error_packet( node, "feature-not-implemented", "cancel", NULL ); 120 123 pack = 0; 121 124 } … … 123 126 else if( strcmp( type, "set" ) == 0 ) 124 127 { 125 if( !( c = xt_find_node( node->children, "query" ) ) || 128 if( ( c = xt_find_node( node->children, "si" ) ) && 129 ( strcmp( xt_find_attr( c, "xmlns" ), XMLNS_SI ) == 0 ) ) 130 { 131 return jabber_si_handle_request( ic, node, c ); 132 } else if( !( c = xt_find_node( node->children, "query" ) ) || 126 133 !( s = xt_find_attr( c, "xmlns" ) ) ) 127 134 { 128 135 imcb_log( ic, "Warning: Received incomplete IQ-%s packet", type ); 129 136 return XT_HANDLED; 130 } 131 137 } else if( strcmp( s, XMLNS_ROSTER ) == 0 ) 138 { 132 139 /* This is a roster push. XMPP servers send this when someone 133 140 was added to (or removed from) the buddy list. AFAIK they're 134 141 sent even if we added this buddy in our own session. */ 135 if( strcmp( s, XMLNS_ROSTER ) == 0 )136 {137 142 int bare_len = strlen( ic->acc->user ); 138 143 … … 151 156 152 157 xt_free_node( reply ); 153 reply = jabber_make_error_packet( node, "not-allowed", "cancel" );158 reply = jabber_make_error_packet( node, "not-allowed", "cancel", NULL ); 154 159 pack = 0; 155 160 } 156 } 157 else 161 } else if( strcmp( s, XMLNS_BYTESTREAMS ) == 0 ) 162 { 163 /* Bytestream Request (stage 2 of file transfer) */ 164 return jabber_bs_recv_request( ic, node, c ); 165 } else 158 166 { 159 167 xt_free_node( reply ); 160 reply = jabber_make_error_packet( node, "feature-not-implemented", "cancel" );168 reply = jabber_make_error_packet( node, "feature-not-implemented", "cancel", NULL ); 161 169 pack = 0; 162 170 } … … 593 601 return st; 594 602 } 603 604 xt_status jabber_iq_parse_features( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 605 606 xt_status jabber_iq_query_features( struct im_connection *ic, char *bare_jid ) 607 { 608 struct xt_node *node, *query; 609 struct jabber_buddy *bud; 610 611 if( ( bud = jabber_buddy_by_jid( ic, bare_jid , 0 ) ) == NULL ) 612 { 613 /* Who cares about the unknown... */ 614 imcb_log( ic, "Couldn't find buddy: %s", bare_jid); 615 return 0; 616 } 617 618 if( bud->features ) /* been here already */ 619 return XT_HANDLED; 620 621 node = xt_new_node( "query", NULL, NULL ); 622 xt_add_attr( node, "xmlns", XMLNS_DISCO_INFO ); 623 624 if( !( query = jabber_make_packet( "iq", "get", bare_jid, node ) ) ) 625 { 626 imcb_log( ic, "WARNING: Couldn't generate feature query" ); 627 xt_free_node( node ); 628 return 0; 629 } 630 631 jabber_cache_add( ic, query, jabber_iq_parse_features ); 632 633 return jabber_write_packet( ic, query ); 634 } 635 636 xt_status jabber_iq_parse_features( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) 637 { 638 struct xt_node *c; 639 struct jabber_buddy *bud; 640 char *feature; 641 642 if( !( c = xt_find_node( node->children, "query" ) ) || 643 !( strcmp( xt_find_attr( c, "xmlns" ), XMLNS_DISCO_INFO ) == 0 ) ) 644 { 645 imcb_log( ic, "WARNING: Received incomplete IQ-result packet for discover" ); 646 return XT_HANDLED; 647 } 648 if( ( bud = jabber_buddy_by_jid( ic, xt_find_attr( node, "from") , 0 ) ) == NULL ) 649 { 650 /* Who cares about the unknown... */ 651 imcb_log( ic, "Couldn't find buddy: %s", xt_find_attr( node, "from")); 652 return 0; 653 } 654 655 c = c->children; 656 while( ( c = xt_find_node( c, "feature" ) ) ) { 657 feature = xt_find_attr( c, "var" ); 658 bud->features = g_slist_append(bud->features, g_strdup(feature) ); 659 c = c->next; 660 } 661 662 return XT_HANDLED; 663 } 664 665 xt_status jabber_iq_parse_server_features( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 666 667 xt_status jabber_iq_query_server( struct im_connection *ic, char *jid, char *xmlns ) 668 { 669 struct xt_node *node, *query; 670 struct jabber_data *jd = ic->proto_data; 671 672 node = xt_new_node( "query", NULL, NULL ); 673 xt_add_attr( node, "xmlns", xmlns ); 674 675 if( !( query = jabber_make_packet( "iq", "get", jid, node ) ) ) 676 { 677 imcb_log( ic, "WARNING: Couldn't generate server query" ); 678 xt_free_node( node ); 679 } 680 681 jd->have_streamhosts--; 682 jabber_cache_add( ic, query, jabber_iq_parse_server_features ); 683 684 return jabber_write_packet( ic, query ); 685 } 686 687 /* 688 * Query the server for "items", query each "item" for identities, query each "item" that's a proxy for it's bytestream info 689 */ 690 xt_status jabber_iq_parse_server_features( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) 691 { 692 struct xt_node *c; 693 struct jabber_data *jd = ic->proto_data; 694 695 if( !( c = xt_find_node( node->children, "query" ) ) || 696 !xt_find_attr( node, "from" ) ) 697 { 698 imcb_log( ic, "WARNING: Received incomplete IQ-result packet for discover" ); 699 return XT_HANDLED; 700 } 701 702 jd->have_streamhosts++; 703 704 if( strcmp( xt_find_attr( c, "xmlns" ), XMLNS_DISCO_ITEMS ) == 0 ) 705 { 706 char *item, *itemjid; 707 708 /* answer from server */ 709 710 c = c->children; 711 while( ( c = xt_find_node( c, "item" ) ) ) 712 { 713 item = xt_find_attr( c, "name" ); 714 itemjid = xt_find_attr( c, "jid" ); 715 716 jabber_iq_query_server( ic, itemjid, XMLNS_DISCO_INFO ); 717 718 c = c->next; 719 } 720 } else if( strcmp( xt_find_attr( c, "xmlns" ), XMLNS_DISCO_INFO ) == 0 ) 721 { 722 char *category, *type; 723 724 /* answer from potential proxy */ 725 726 c = c->children; 727 while( ( c = xt_find_node( c, "identity" ) ) ) 728 { 729 category = xt_find_attr( c, "category" ); 730 type = xt_find_attr( c, "type" ); 731 732 if( type && ( strcmp( type, "bytestreams" ) == 0 ) && 733 category && ( strcmp( category, "proxy" ) == 0 ) ) 734 jabber_iq_query_server( ic, xt_find_attr( node, "from" ), XMLNS_BYTESTREAMS ); 735 736 c = c->next; 737 } 738 } else if( strcmp( xt_find_attr( c, "xmlns" ), XMLNS_BYTESTREAMS ) == 0 ) 739 { 740 char *host, *jid; 741 int port; 742 743 /* answer from proxy */ 744 745 if( ( c = xt_find_node( c->children, "streamhost" ) ) && 746 ( host = xt_find_attr( c, "host" ) ) && 747 ( port = atoi( xt_find_attr( c, "port" ) ) ) && 748 ( jid = xt_find_attr( c, "jid" ) ) ) 749 { 750 jabber_streamhost_t *sh = g_new0( jabber_streamhost_t, 1 ); 751 sh->jid = g_strdup( jid ); 752 sh->host = g_strdup( host ); 753 sprintf( sh->port, "%u", port ); 754 755 imcb_log( ic, "Proxy found: jid %s host %s port %u", jid, host, port ); 756 jd->streamhosts = g_slist_append( jd->streamhosts, sh ); 757 } 758 } 759 760 if( jd->have_streamhosts == 0 ) 761 jd->have_streamhosts++; 762 return XT_HANDLED; 763 }
Note: See TracChangeset
for help on using the changeset viewer.