soc.2008.xmpp: 7cc51f30: * pass hash type to the caps handling fu...
tfar at soc.pidgin.im
tfar at soc.pidgin.im
Sun Jul 6 17:16:41 EDT 2008
-----------------------------------------------------------------
Revision: 7cc51f307fb181681a680465abf9444546024d98
Ancestor: 205109eaadff2ff58bf4efc9835a366792efed23
Author: tfar at soc.pidgin.im
Date: 2008-07-01T23:16:15
Branch: im.pidgin.soc.2008.xmpp
URL: http://d.pidgin.im/viewmtn/revision/info/7cc51f307fb181681a680465abf9444546024d98
Modified files:
libpurple/protocols/jabber/caps.c
libpurple/protocols/jabber/caps.h
libpurple/protocols/jabber/presence.c
ChangeLog:
* pass hash type to the caps handling functions
* fix small bug in generation of caps hash
* removed a bit debugging output
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/caps.c 3fd3414d7cf44c525d4fe3f1cdfe7f91e784e57f
+++ libpurple/protocols/jabber/caps.c b81f420875f73877e81b4ec6be4a51931e4e9735
@@ -351,6 +351,7 @@ typedef struct _jabber_caps_cbplususerda
char *node;
char *ver;
GList *ext;
+ char *hash;
unsigned extOutstanding;
} jabber_caps_cbplususerdata;
@@ -446,9 +447,16 @@ static void jabber_caps_client_iqcb(Jabb
jabber_caps_cbplususerdata *userdata = data;
/* TODO: Better error checking! */
- printf("\n\tjabber_caps_client_iqcb for %s", xmlnode_get_attrib(packet, "from"));
if (query) {
+ // check hash
+ JabberCapsClientInfo *info = jabber_caps_parse_client_info(query);
+ gchar *sha_hash = jabber_caps_calcualte_hash(info);
+ #warning INSERT HASH CHECKING CODE HERE! ONLY ADD TO CACHE IF HASH IS THE SAME.
+
+ g_free(info);
+ g_free(sha_hash);
+
JabberCapsValue *value = g_new0(JabberCapsValue, 1);
JabberCapsKey *key = g_new0(JabberCapsKey, 1);
@@ -501,7 +509,7 @@ static void jabber_caps_client_iqcb(Jabb
jabber_caps_get_info_check_completion(userdata);
}
-void jabber_caps_get_info(JabberStream *js, const char *who, const char *node, const char *ver, const char *ext, jabber_caps_get_info_cb cb, gpointer user_data) {
+void jabber_caps_get_info(JabberStream *js, const char *who, const char *node, const char *ver, const char *hash, jabber_caps_get_info_cb cb, gpointer user_data) {
JabberCapsValue *client;
JabberCapsKey *key = g_new0(JabberCapsKey, 1);
jabber_caps_cbplususerdata *userdata = g_new0(jabber_caps_cbplususerdata, 1);
@@ -510,6 +518,7 @@ void jabber_caps_get_info(JabberStream *
userdata->who = g_strdup(who);
userdata->node = g_strdup(node);
userdata->ver = g_strdup(ver);
+ userdata->hash = g_strdup(hash);
key->node = (char *)node;
key->ver = (char *)ver;
@@ -745,7 +754,7 @@ gchar *jabber_caps_calcualte_hash(Jabber
/* concat features to the verification string */
for(features = info->features; features; features = features->next) {
- feature_string = g_strdup_printf("%s<", (gchar*)features->data);
+ feature_string = g_strdup_printf("%s", (gchar*)features->data);
verification = jabber_caps_verification_append(verification, feature_string);
g_free(feature_string);
}
@@ -761,7 +770,7 @@ gchar *jabber_caps_calcualte_hash(Jabber
for(fields = jabber_caps_xdata_get_fields((xmlnode*)(xdata->data)); fields != 0; fields = fields->next) {
GList *value;
- JabberDataFormField *field = (JabberDataFormField*)fields;
+ JabberDataFormField *field = (JabberDataFormField*)fields->data;
if(strcmp(field->var, "FORM_TYPE")) {
/* Append the value of the "var" attribute, followed by the '<' character. */
verification = jabber_caps_verification_append(verification, field->var);
@@ -778,7 +787,7 @@ gchar *jabber_caps_calcualte_hash(Jabber
}
g_list_free(fields);
}
-
+
/* generate SHA-1 hash */
context = purple_cipher_context_new_by_name("sha1", NULL);
if (context == NULL) {
@@ -796,7 +805,6 @@ gchar *jabber_caps_calcualte_hash(Jabber
g_free(verification);
verification = purple_base64_encode(checksum, checksum_size);
- printf("\n%s", verification);
if (caps_hash != 0) g_free(caps_hash);
return verification;
============================================================
--- libpurple/protocols/jabber/caps.h b70d9d20ba848ce49c5df9c36397889c80e70bd0
+++ libpurple/protocols/jabber/caps.h 45afe34c1f633fc9f2aea3dffbfd5734b36ee7c8
@@ -45,7 +45,10 @@ void jabber_caps_init(void);
void jabber_caps_init(void);
-void jabber_caps_get_info(JabberStream *js, const char *who, const char *node, const char *ver, const char *ext, jabber_caps_get_info_cb cb, gpointer user_data);
+/**
+ * Main entity capabilites function to get the capabilities of a contact.
+ */
+void jabber_caps_get_info(JabberStream *js, const char *who, const char *node, const char *ver, const char *hash, jabber_caps_get_info_cb cb, gpointer user_data);
void jabber_caps_free_clientinfo(JabberCapsClientInfo *clientinfo);
/**
============================================================
--- libpurple/protocols/jabber/presence.c 11c8ee00154a052f6c876f46bf3910aa38a8e0cb
+++ libpurple/protocols/jabber/presence.c 6ae59cd461225842009b2c824435d2575e86c279
@@ -750,16 +750,17 @@ void jabber_presence_parse(JabberStream
jbr = jabber_buddy_track_resource(jb, jid->resource, priority,
state, status);
if(caps) {
+ /* handle XEP-0115 */
const char *node = xmlnode_get_attrib(caps,"node");
const char *ver = xmlnode_get_attrib(caps,"ver");
- const char *ext = xmlnode_get_attrib(caps,"ext");
+ const char *hash = xmlnode_get_attrib(caps,"hash");
- if(node && ver) {
+ if(node && ver && hash) {
JabberPresenceCapabilities *userdata = g_new0(JabberPresenceCapabilities, 1);
userdata->js = js;
userdata->jb = jb;
userdata->from = g_strdup(from);
- jabber_caps_get_info(js, from, node, ver, ext, jabber_presence_set_capabilities, userdata);
+ jabber_caps_get_info(js, from, node, ver, hash, jabber_presence_set_capabilities, userdata);
}
}
}
More information about the Commits
mailing list