Mercurial > pidgin.yaz
diff 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 |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/parser.c Tue Mar 09 22:44:59 2010 +0000 +++ b/libpurple/protocols/jabber/parser.c Tue Mar 09 23:09:54 2010 +0000 @@ -44,15 +44,26 @@ if(!element_name) { return; } else if(!xmlStrcmp(element_name, (xmlChar*) "stream")) { - js->protocol_version = JABBER_PROTO_0_9; + js->protocol_version.major = 0; + js->protocol_version.minor = 9; for(i=0; i < nb_attributes * 5; i += 5) { int attrib_len = attributes[i+4] - attributes[i+3]; char *attrib = g_strndup((gchar *)attributes[i+3], attrib_len); - if(!xmlStrcmp(attributes[i], (xmlChar*) "version") - && !strcmp(attrib, "1.0")) { - js->protocol_version = JABBER_PROTO_1_0; + if(!xmlStrcmp(attributes[i], (xmlChar*) "version")) { + const char *dot = strchr(attrib, '.'); + + js->protocol_version.major = atoi(attrib); + js->protocol_version.minor = dot ? atoi(dot + 1) : 0; g_free(attrib); + + /* TODO: Check this against the spec; I'm not sure if the check + * against minor is accurate. + */ + if (js->protocol_version.major > 1 || js->protocol_version.minor > 0) + purple_connection_error_reason(js->gc, + PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, + _("XMPP Version Mismatch")); } else if(!xmlStrcmp(attributes[i], (xmlChar*) "id")) { g_free(js->stream_id); js->stream_id = attrib; @@ -255,7 +266,8 @@ } } - if (js->protocol_version == JABBER_PROTO_0_9 && !js->gc->disconnect_timeout && + if (js->protocol_version.major == 0 && js->protocol_version.minor == 9 && + !js->gc->disconnect_timeout && (js->state == JABBER_STREAM_INITIALIZING || js->state == JABBER_STREAM_INITIALIZING_ENCRYPTION)) { /*