Mercurial > pidgin
comparison libpurple/protocols/jabber/bosh.c @ 25056:94ccccab4e98
* free xmlnodes after bosh receive callback is called
author | Tobias Markmann <tfar@soc.pidgin.im> |
---|---|
date | Mon, 18 Aug 2008 17:08:01 +0000 |
parents | 480736bfcf45 |
children | 7de1f124f95a |
comparison
equal
deleted
inserted
replaced
25055:480736bfcf45 | 25056:94ccccab4e98 |
---|---|
73 } | 73 } |
74 | 74 |
75 gboolean jabber_bosh_connection_error_check(PurpleBOSHConnection *conn, xmlnode *node) { | 75 gboolean jabber_bosh_connection_error_check(PurpleBOSHConnection *conn, xmlnode *node) { |
76 char *type; | 76 char *type; |
77 | 77 |
78 if (!node) return; | 78 if (!node) return FALSE; |
79 type = xmlnode_get_attrib(node, "type"); | 79 type = xmlnode_get_attrib(node, "type"); |
80 | 80 |
81 if (type != NULL && !strcmp(type, "terminate")) { | 81 if (type != NULL && !strcmp(type, "terminate")) { |
82 conn->ready = FALSE; | 82 conn->ready = FALSE; |
83 purple_connection_error_reason (conn->js->gc, | 83 purple_connection_error_reason (conn->js->gc, |
106 } | 106 } |
107 jabber_process_packet(js, &child); | 107 jabber_process_packet(js, &child); |
108 } | 108 } |
109 child = child->next; | 109 child = child->next; |
110 } | 110 } |
111 xmlnode_free(node); | |
112 } | 111 } |
113 | 112 |
114 void jabber_bosh_connection_auth_response(PurpleBOSHConnection *conn, xmlnode *node) { | 113 void jabber_bosh_connection_auth_response(PurpleBOSHConnection *conn, xmlnode *node) { |
115 xmlnode *child = node->child; | 114 xmlnode *child = node->child; |
116 | 115 |
142 conn->sid = g_strdup(xmlnode_get_attrib(node, "sid")); | 141 conn->sid = g_strdup(xmlnode_get_attrib(node, "sid")); |
143 } else { | 142 } else { |
144 purple_debug_info("jabber", "Connection manager doesn't behave BOSH-like!\n"); | 143 purple_debug_info("jabber", "Connection manager doesn't behave BOSH-like!\n"); |
145 } | 144 } |
146 | 145 |
147 if (version = xmlnode_get_attrib(node, "ver")) { | 146 if ((version = xmlnode_get_attrib(node, "ver"))) { |
148 version[1] = 0; | 147 version[1] = 0; |
149 if (!(atoi(version) >= 1 && atoi(&version[2]) >= 6)) purple_debug_info("jabber", "Unsupported version of BOSH protocol. The connection manager must at least support version 1.6!\n"); | 148 if (!(atoi(version) >= 1 && atoi(&version[2]) >= 6)) purple_debug_info("jabber", "Unsupported version of BOSH protocol. The connection manager must at least support version 1.6!\n"); |
150 else { | 149 else { |
151 xmlnode *packet = xmlnode_get_child(node, "features"); | 150 xmlnode *packet = xmlnode_get_child(node, "features"); |
152 conn->js->use_bosh = TRUE; | 151 conn->js->use_bosh = TRUE; |
188 if (node) { | 187 if (node) { |
189 char *txt = xmlnode_to_formatted_str(node, NULL); | 188 char *txt = xmlnode_to_formatted_str(node, NULL); |
190 printf("\njabber_bosh_connection_http_received_cb\n%s\n", txt); | 189 printf("\njabber_bosh_connection_http_received_cb\n%s\n", txt); |
191 g_free(txt); | 190 g_free(txt); |
192 conn->receive_cb(conn, node); | 191 conn->receive_cb(conn, node); |
192 xmlnode_free(node); | |
193 } else { | 193 } else { |
194 printf("\njabber_bosh_connection_http_received_cb: XML ERROR: %s\n", res->data); | 194 printf("\njabber_bosh_connection_http_received_cb: XML ERROR: %s\n", res->data); |
195 } | 195 } |
196 } else purple_debug_info("jabber", "missing receive_cb of PurpleBOSHConnection.\n"); | 196 } else purple_debug_info("jabber", "missing receive_cb of PurpleBOSHConnection.\n"); |
197 } | 197 } |
437 | 437 |
438 void jabber_bosh_http_request_clean(PurpleHTTPRequest *req) { | 438 void jabber_bosh_http_request_clean(PurpleHTTPRequest *req) { |
439 g_hash_table_destroy(req->header); | 439 g_hash_table_destroy(req->header); |
440 g_free(req->method); | 440 g_free(req->method); |
441 g_free(req->path); | 441 g_free(req->path); |
442 g_free(req->data); | |
442 } | 443 } |
443 | 444 |
444 void jabber_bosh_http_response_init(PurpleHTTPResponse *res) { | 445 void jabber_bosh_http_response_init(PurpleHTTPResponse *res) { |
445 res->status = 0; | 446 res->status = 0; |
446 res->header = g_hash_table_new(g_str_hash, g_str_equal); | 447 res->header = g_hash_table_new(g_str_hash, g_str_equal); |
447 } | 448 } |
448 | 449 |
449 | 450 |
450 void jabber_bosh_http_response_clean(PurpleHTTPResponse *res) { | 451 void jabber_bosh_http_response_clean(PurpleHTTPResponse *res) { |
451 //g_hash_table_destroy(res->header); | 452 g_hash_table_destroy(res->header); |
452 g_free(res->data); | 453 g_free(res->data); |
453 } | 454 } |