Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/parser.c @ 29961:618c4165d4f8
jabber: Treat the version properly.
Granted, consensus among XMPP folks is that bumping the minor would break
almost everything, but that's no reason not to be accurate ourselves.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Tue, 09 Mar 2010 23:09:54 +0000 |
parents | 05d727f76ca9 |
children | 32fe87f58d06 |
comparison
equal
deleted
inserted
replaced
29960:13f320cde14f | 29961:618c4165d4f8 |
---|---|
42 int i, j; | 42 int i, j; |
43 | 43 |
44 if(!element_name) { | 44 if(!element_name) { |
45 return; | 45 return; |
46 } else if(!xmlStrcmp(element_name, (xmlChar*) "stream")) { | 46 } else if(!xmlStrcmp(element_name, (xmlChar*) "stream")) { |
47 js->protocol_version = JABBER_PROTO_0_9; | 47 js->protocol_version.major = 0; |
48 js->protocol_version.minor = 9; | |
48 for(i=0; i < nb_attributes * 5; i += 5) { | 49 for(i=0; i < nb_attributes * 5; i += 5) { |
49 int attrib_len = attributes[i+4] - attributes[i+3]; | 50 int attrib_len = attributes[i+4] - attributes[i+3]; |
50 char *attrib = g_strndup((gchar *)attributes[i+3], attrib_len); | 51 char *attrib = g_strndup((gchar *)attributes[i+3], attrib_len); |
51 | 52 |
52 if(!xmlStrcmp(attributes[i], (xmlChar*) "version") | 53 if(!xmlStrcmp(attributes[i], (xmlChar*) "version")) { |
53 && !strcmp(attrib, "1.0")) { | 54 const char *dot = strchr(attrib, '.'); |
54 js->protocol_version = JABBER_PROTO_1_0; | 55 |
56 js->protocol_version.major = atoi(attrib); | |
57 js->protocol_version.minor = dot ? atoi(dot + 1) : 0; | |
55 g_free(attrib); | 58 g_free(attrib); |
59 | |
60 /* TODO: Check this against the spec; I'm not sure if the check | |
61 * against minor is accurate. | |
62 */ | |
63 if (js->protocol_version.major > 1 || js->protocol_version.minor > 0) | |
64 purple_connection_error_reason(js->gc, | |
65 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, | |
66 _("XMPP Version Mismatch")); | |
56 } else if(!xmlStrcmp(attributes[i], (xmlChar*) "id")) { | 67 } else if(!xmlStrcmp(attributes[i], (xmlChar*) "id")) { |
57 g_free(js->stream_id); | 68 g_free(js->stream_id); |
58 js->stream_id = attrib; | 69 js->stream_id = attrib; |
59 } else { | 70 } else { |
60 g_free(attrib); | 71 g_free(attrib); |
253 _("XML Parse error")); | 264 _("XML Parse error")); |
254 break; | 265 break; |
255 } | 266 } |
256 } | 267 } |
257 | 268 |
258 if (js->protocol_version == JABBER_PROTO_0_9 && !js->gc->disconnect_timeout && | 269 if (js->protocol_version.major == 0 && js->protocol_version.minor == 9 && |
270 !js->gc->disconnect_timeout && | |
259 (js->state == JABBER_STREAM_INITIALIZING || | 271 (js->state == JABBER_STREAM_INITIALIZING || |
260 js->state == JABBER_STREAM_INITIALIZING_ENCRYPTION)) { | 272 js->state == JABBER_STREAM_INITIALIZING_ENCRYPTION)) { |
261 /* | 273 /* |
262 * Legacy servers don't advertise features, so if we've just gotten | 274 * Legacy servers don't advertise features, so if we've just gotten |
263 * the opening <stream:stream> and there was no version, we need to | 275 * the opening <stream:stream> and there was no version, we need to |