comparison libpurple/protocols/jabber/jabber.c @ 29692:fb99a0067812

propagate from branch 'im.pidgin.pidgin' (head 70d69397ed952b26b453423c381c70d6783eb66d) to branch 'im.pidgin.cpw.attention_ui' (head 1cf0dea282a0d0e4aeac4770e0150d6d0c10830a)
author Marcus Lundblad <ml@update.uu.se>
date Thu, 13 Aug 2009 17:42:44 +0000
parents 338d6a211055 eb2d17945ce3
children 7925bb7f2aa7
comparison
equal deleted inserted replaced
29691:338d6a211055 29692:fb99a0067812
130 if (type == JABBER_IQ_RESULT && 130 if (type == JABBER_IQ_RESULT &&
131 (bind = xmlnode_get_child_with_namespace(packet, "bind", "urn:ietf:params:xml:ns:xmpp-bind"))) { 131 (bind = xmlnode_get_child_with_namespace(packet, "bind", "urn:ietf:params:xml:ns:xmpp-bind"))) {
132 xmlnode *jid; 132 xmlnode *jid;
133 char *full_jid; 133 char *full_jid;
134 if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) { 134 if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) {
135 JabberBuddy *my_jb = NULL;
136 jabber_id_free(js->user); 135 jabber_id_free(js->user);
137 if(!(js->user = jabber_id_new(full_jid))) { 136
137 js->user = jabber_id_new(full_jid);
138 if (js->user == NULL) {
138 purple_connection_error_reason(js->gc, 139 purple_connection_error_reason(js->gc,
139 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 140 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
140 _("Invalid response from server")); 141 _("Invalid response from server"));
142 g_free(full_jid);
143 return;
141 } 144 }
142 if((my_jb = jabber_buddy_find(js, full_jid, TRUE))) 145
143 my_jb->subscription |= JABBER_SUB_BOTH; 146 js->user_jb = jabber_buddy_find(js, full_jid, TRUE);
147 js->user_jb->subscription |= JABBER_SUB_BOTH;
144 148
145 purple_connection_set_display_name(js->gc, full_jid); 149 purple_connection_set_display_name(js->gc, full_jid);
146 150
147 g_free(full_jid); 151 g_free(full_jid);
148 } 152 }
439 #endif 443 #endif
440 444
441 if (len == -1) 445 if (len == -1)
442 len = strlen(data); 446 len = strlen(data);
443 447
444 if (js->use_bosh) 448 if (js->bosh)
445 jabber_bosh_connection_send_raw(js->bosh, data); 449 jabber_bosh_connection_send_raw(js->bosh, data);
446 else 450 else
447 do_jabber_send_raw(js, data, len); 451 do_jabber_send_raw(js, data, len);
448 } 452 }
449 453
463 467
464 if (NULL == packet) 468 if (NULL == packet)
465 return; 469 return;
466 470
467 js = purple_connection_get_protocol_data(pc); 471 js = purple_connection_get_protocol_data(pc);
468 if (js->use_bosh) 472 if (js->bosh)
469 if (g_str_equal((*packet)->name, "message") || 473 if (g_str_equal((*packet)->name, "message") ||
470 g_str_equal((*packet)->name, "iq") || 474 g_str_equal((*packet)->name, "iq") ||
471 g_str_equal((*packet)->name, "presence")) 475 g_str_equal((*packet)->name, "presence"))
472 xmlnode_set_namespace(*packet, "jabber:client"); 476 xmlnode_set_namespace(*packet, "jabber:client");
473 txt = xmlnode_to_str(*packet, &len); 477 txt = xmlnode_to_str(*packet, &len);
630 gchar **token; 634 gchar **token;
631 token = g_strsplit(purple_txt_response_get_content(resp), "=", 2); 635 token = g_strsplit(purple_txt_response_get_content(resp), "=", 2);
632 if (!strcmp(token[0], "_xmpp-client-xbosh")) { 636 if (!strcmp(token[0], "_xmpp-client-xbosh")) {
633 purple_debug_info("jabber","Found alternative connection method using %s at %s.\n", token[0], token[1]); 637 purple_debug_info("jabber","Found alternative connection method using %s at %s.\n", token[0], token[1]);
634 js->bosh = jabber_bosh_connection_init(js, token[1]); 638 js->bosh = jabber_bosh_connection_init(js, token[1]);
635 js->use_bosh = TRUE;
636 g_strfreev(token); 639 g_strfreev(token);
637 break; 640 break;
638 } 641 }
639 g_strfreev(token); 642 g_strfreev(token);
640 purple_txt_response_destroy(resp); 643 purple_txt_response_destroy(resp);
774 static JabberStream * 777 static JabberStream *
775 jabber_stream_new(PurpleAccount *account) 778 jabber_stream_new(PurpleAccount *account)
776 { 779 {
777 PurpleConnection *gc = purple_account_get_connection(account); 780 PurpleConnection *gc = purple_account_get_connection(account);
778 JabberStream *js; 781 JabberStream *js;
779 JabberBuddy *my_jb;
780 PurplePresence *presence; 782 PurplePresence *presence;
781 gchar *user; 783 gchar *user;
782 gchar *slash; 784 gchar *slash;
783 785
784 js = gc->proto_data = g_new0(JabberStream, 1); 786 js = gc->proto_data = g_new0(JabberStream, 1);
809 } 811 }
810 812
811 js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal, 813 js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal,
812 g_free, (GDestroyNotify)jabber_buddy_free); 814 g_free, (GDestroyNotify)jabber_buddy_free);
813 815
814 my_jb = jabber_buddy_find(js, user, TRUE); 816 js->user_jb = jabber_buddy_find(js, user, TRUE);
815 g_free(user); 817 g_free(user);
816 if (!my_jb) { 818 if (!js->user_jb) {
817 /* This basically *can't* fail, but for good measure... */ 819 /* This basically *can't* fail, but for good measure... */
818 purple_connection_error_reason(gc, 820 purple_connection_error_reason(gc,
819 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, 821 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
820 _("Invalid XMPP ID")); 822 _("Invalid XMPP ID"));
821 /* Destroying the connection will free the JabberStream */ 823 /* Destroying the connection will free the JabberStream */
822 g_return_val_if_reached(NULL); 824 g_return_val_if_reached(NULL);
823 } 825 }
824 826
825 my_jb->subscription |= JABBER_SUB_BOTH; 827 js->user_jb->subscription |= JABBER_SUB_BOTH;
826 828
827 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, 829 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal,
828 g_free, g_free); 830 g_free, g_free);
829 js->chats = g_hash_table_new_full(g_str_hash, g_str_equal, 831 js->chats = g_hash_table_new_full(g_str_hash, g_str_equal,
830 g_free, (GDestroyNotify)jabber_chat_free); 832 g_free, (GDestroyNotify)jabber_chat_free);
863 865
864 /* If both BOSH and a Connect Server are specified, we prefer BOSH. I'm not 866 /* If both BOSH and a Connect Server are specified, we prefer BOSH. I'm not
865 * attached to that choice, though. 867 * attached to that choice, though.
866 */ 868 */
867 if (*bosh_url) { 869 if (*bosh_url) {
868 js->use_bosh = TRUE;
869 js->bosh = jabber_bosh_connection_init(js, bosh_url); 870 js->bosh = jabber_bosh_connection_init(js, bosh_url);
870 if (js->bosh) 871 if (js->bosh)
871 jabber_bosh_connection_connect(js->bosh); 872 jabber_bosh_connection_connect(js->bosh);
872 else { 873 else {
873 purple_connection_error_reason(gc, 874 purple_connection_error_reason(gc,
1443 /* Don't perform any actions on the ssl connection 1444 /* Don't perform any actions on the ssl connection
1444 * if we were forcibly disconnected because it will crash 1445 * if we were forcibly disconnected because it will crash
1445 * on some SSL backends. 1446 * on some SSL backends.
1446 */ 1447 */
1447 if (!gc->disconnect_timeout) { 1448 if (!gc->disconnect_timeout) {
1448 if (js->use_bosh) 1449 if (js->bosh)
1449 jabber_bosh_connection_close(js->bosh); 1450 jabber_bosh_connection_close(js->bosh);
1450 else if ((js->gsc && js->gsc->fd > 0) || js->fd > 0) 1451 else if ((js->gsc && js->gsc->fd > 0) || js->fd > 0)
1451 jabber_send_raw(js, "</stream:stream>", -1); 1452 jabber_send_raw(js, "</stream:stream>", -1);
1452 } 1453 }
1453 1454
1539 g_free(js->old_title); 1540 g_free(js->old_title);
1540 g_free(js->old_source); 1541 g_free(js->old_source);
1541 g_free(js->old_uri); 1542 g_free(js->old_uri);
1542 g_free(js->old_track); 1543 g_free(js->old_track);
1543 g_free(js->expected_rspauth); 1544 g_free(js->expected_rspauth);
1545
1546 if (js->vcard_timer != 0)
1547 purple_timeout_remove(js->vcard_timer);
1544 1548
1545 if (js->keepalive_timeout != 0) 1549 if (js->keepalive_timeout != 0)
1546 purple_timeout_remove(js->keepalive_timeout); 1550 purple_timeout_remove(js->keepalive_timeout);
1547 1551
1548 g_free(js->srv_rec); 1552 g_free(js->srv_rec);
3462 jabber_add_feature(JINGLE_TRANSPORT_RAWUDP, 0); 3466 jabber_add_feature(JINGLE_TRANSPORT_RAWUDP, 0);
3463 3467
3464 #ifdef USE_VV 3468 #ifdef USE_VV
3465 jabber_add_feature("http://www.google.com/xmpp/protocol/session", jabber_audio_enabled); 3469 jabber_add_feature("http://www.google.com/xmpp/protocol/session", jabber_audio_enabled);
3466 jabber_add_feature("http://www.google.com/xmpp/protocol/voice/v1", jabber_audio_enabled); 3470 jabber_add_feature("http://www.google.com/xmpp/protocol/voice/v1", jabber_audio_enabled);
3471 jabber_add_feature("http://www.google.com/xmpp/protocol/video/v1", jabber_video_enabled);
3472 jabber_add_feature("http://www.google.com/xmpp/protocol/camera/v1", jabber_video_enabled);
3467 jabber_add_feature(JINGLE_APP_RTP_SUPPORT_AUDIO, jabber_audio_enabled); 3473 jabber_add_feature(JINGLE_APP_RTP_SUPPORT_AUDIO, jabber_audio_enabled);
3468 jabber_add_feature(JINGLE_APP_RTP_SUPPORT_VIDEO, jabber_video_enabled); 3474 jabber_add_feature(JINGLE_APP_RTP_SUPPORT_VIDEO, jabber_video_enabled);
3469 jabber_add_feature(JINGLE_TRANSPORT_ICEUDP, 0); 3475 jabber_add_feature(JINGLE_TRANSPORT_ICEUDP, 0);
3470 #endif 3476 #endif
3471 3477