Mercurial > pidgin
comparison libpurple/protocols/jabber/bosh.c @ 25050:a03a953ba63d
* moving BOSH interfacing from jabber_send to jabber_send_raw
* sending BOSH stream restart after successful SASL login
author | Tobias Markmann <tfar@soc.pidgin.im> |
---|---|
date | Fri, 15 Aug 2008 16:35:32 +0000 |
parents | f775f6021654 |
children | 5f70e13db5cc |
comparison
equal
deleted
inserted
replaced
25049:f775f6021654 | 25050:a03a953ba63d |
---|---|
54 conn->conn_a = g_new0(PurpleHTTPConnection, 1); | 54 conn->conn_a = g_new0(PurpleHTTPConnection, 1); |
55 jabber_bosh_http_connection_init(conn->conn_a, conn->account, conn->host, conn->port); | 55 jabber_bosh_http_connection_init(conn->conn_a, conn->account, conn->host, conn->port); |
56 conn->conn_a->userdata = conn; | 56 conn->conn_a->userdata = conn; |
57 } | 57 } |
58 | 58 |
59 void jabber_bosh_connection_stream_restart(PurpleBOSHConnection *conn) { | |
60 /* | |
61 <body rid='1573741824' | |
62 sid='SomeSID' | |
63 to='jabber.org' | |
64 xml:lang='en' | |
65 xmpp:restart='true' | |
66 xmlns='http://jabber.org/protocol/httpbind' | |
67 xmlns:xmpp='urn:xmpp:xbosh'/> | |
68 */ | |
69 xmlnode *restart = xmlnode_new("body"); | |
70 char *tmp = NULL; | |
71 conn->rid++; | |
72 xmlnode_set_attrib(restart, "rid", tmp = g_strdup_printf("%d", conn->rid)); | |
73 g_free(tmp); | |
74 xmlnode_set_attrib(restart, "sid", conn->sid); | |
75 xmlnode_set_attrib(restart, "to", conn->js->user->domain); | |
76 xmlnode_set_attrib(restart, "xml:lang", "en"); | |
77 xmlnode_set_attrib(restart, "xmpp:restart", "true"); | |
78 xmlnode_set_attrib(restart, "xmlns", "http://jabber.org/protocol/httpbind"); | |
79 xmlnode_set_attrib(restart, "xmlns:xmpp", "urn:xmpp:xbosh"); | |
80 | |
81 jabber_bosh_connection_send_native(conn, restart); | |
82 } | |
83 | |
84 void jabber_bosh_connection_received(PurpleBOSHConnection *conn, xmlnode *node) { | |
85 | |
86 xmlnode_free(node); | |
87 } | |
88 | |
59 void jabber_bosh_connection_auth_response(PurpleBOSHConnection *conn, xmlnode *node) { | 89 void jabber_bosh_connection_auth_response(PurpleBOSHConnection *conn, xmlnode *node) { |
60 | 90 xmlnode *child = node->child; |
91 | |
92 while(child != NULL && child->type != XMLNODE_TYPE_TAG) { | |
93 child = child->next; | |
94 } | |
95 | |
96 if (child != NULL && child->type == XMLNODE_TYPE_TAG) { | |
97 JabberStream *js = conn->js; | |
98 if (!strcmp(child->name, "success")) { | |
99 jabber_bosh_connection_stream_restart(conn); | |
100 jabber_process_packet(js, &child); | |
101 } else { | |
102 js->state = JABBER_STREAM_AUTHENTICATING; | |
103 conn->receive_cb = jabber_bosh_connection_received; | |
104 jabber_process_packet(js, &child); | |
105 } | |
106 } else printf("\n!! no child!!\n"); | |
61 } | 107 } |
62 | 108 |
63 void jabber_bosh_connection_boot_response(PurpleBOSHConnection *conn, xmlnode *node) { | 109 void jabber_bosh_connection_boot_response(PurpleBOSHConnection *conn, xmlnode *node) { |
64 char *version; | 110 char *version; |
65 if (xmlnode_get_attrib(node, "sid")) { | 111 if (xmlnode_get_attrib(node, "sid")) { |
80 version[1] = '.'; | 126 version[1] = '.'; |
81 } else { | 127 } else { |
82 purple_debug_info("jabber", "Missing version in session creation response!\n"); | 128 purple_debug_info("jabber", "Missing version in session creation response!\n"); |
83 } | 129 } |
84 } | 130 } |
85 | |
86 void jabber_bosh_connection_received(PurpleBOSHConnection *conn, xmlnode *node) { | |
87 xmlnode_free(node); | |
88 } | |
89 | |
90 | 131 |
91 static void jabber_bosh_connection_boot(PurpleBOSHConnection *conn) { | 132 static void jabber_bosh_connection_boot(PurpleBOSHConnection *conn) { |
92 char *tmp; | 133 char *tmp; |
93 xmlnode *init = xmlnode_new("body"); | 134 xmlnode *init = xmlnode_new("body"); |
94 xmlnode_set_attrib(init, "content", "text/xml; charset=utf-8"); | 135 xmlnode_set_attrib(init, "content", "text/xml; charset=utf-8"); |