/soc/2012/sanket/statscollector-2.x.y: 4f83b047b5e4: MD5 account...

Sanket Agarwal sanket at soc.pidgin.im
Tue Jul 10 00:36:22 EDT 2012


Changeset: 4f83b047b5e480b486c8d0bdab790416b5944106
Author:	 Sanket Agarwal <sanket at soc.pidgin.im>
Date:	 2012-05-14 11:23 +0000
Branch:	 soc.2012.statscollector
URL: http://hg.pidgin.im/soc/2012/sanket/statscollector-2.x.y/rev/4f83b047b5e4

Description:

MD5 account id to hide identity

diffstat:

 pidgin/plugins/statscollector.c |  67 +++++++++++++++-------------------------
 1 files changed, 25 insertions(+), 42 deletions(-)

diffs (131 lines):

diff --git a/pidgin/plugins/statscollector.c b/pidgin/plugins/statscollector.c
--- a/pidgin/plugins/statscollector.c
+++ b/pidgin/plugins/statscollector.c
@@ -9,6 +9,9 @@
 #include "signals.h"
 #include "util.h"
 #include "version.h"
+#include "cipher.h"
+#include "prpl.h"
+#include "core.h"
 
 #include <glib.h>
 #include <gtkplugin.h>
@@ -87,7 +90,6 @@
 
   xmlnode *root, *languages, *hardware, *node, *ver, *ver1;
   const char * const * langs;
-  char temp[10];
   int i;
 
   root = xmlnode_new("cpuinfo");
@@ -112,23 +114,7 @@
 
   ver = xmlnode_new("purple-version");
 
-  /* Major version */
-  ver1 = xmlnode_new("major");
-  sprintf(temp, "%d", PURPLE_MAJOR_VERSION);
-  xmlnode_insert_data(ver1, temp, -1);
-  xmlnode_insert_child(ver, ver1);
-
-  /* Minor version */
-  ver1 = xmlnode_new("minor");
-  sprintf(temp, "%d", PURPLE_MINOR_VERSION);
-  xmlnode_insert_data(ver1, temp, -1);
-  xmlnode_insert_child(ver, ver1);
-
-  /* Micro version */
-  ver1 = xmlnode_new("micro");
-  sprintf(temp, "%d", PURPLE_MICRO_VERSION);
-  xmlnode_insert_data(ver1, temp, -1);
-  xmlnode_insert_child(ver, ver1);
+  xmlnode_insert_data(ver, purple_core_get_version(), -1);
 
   /* Add the version information to the root cpuinfo */
   xmlnode_insert_child(root, ver);
@@ -139,6 +125,26 @@
 
 }
 
+
+static const gchar *
+md5(const gchar *str)
+{
+        PurpleCipherContext *context;
+        static gchar digest[41];
+
+        context = purple_cipher_context_new_by_name("md5", NULL);
+        g_return_val_if_fail(context != NULL, NULL);
+
+        purple_cipher_context_append(context, str, strlen(str));
+
+        if (!purple_cipher_context_digest_to_str(context, sizeof(digest), digest, NULL))
+                return NULL;
+
+        purple_cipher_context_destroy(context);
+
+        return digest;
+}
+
 static gchar *
 get_acc_id(char *username, char *prpl_id){
 
@@ -151,11 +157,10 @@
   strcat(id, "-");
   strcat(id, prpl_id);
 
-  return id;
+  return md5(id);
 
 }
 
-
 static void
 acc_sign_on_event(PurpleAccount *account){
 
@@ -182,9 +187,6 @@
 
     acc = xmlnode_new("account");
 
-    /* u_node = xmlnode_new_child(acc, "username"); */
-    /* xmlnode_insert_data(u_node, username, -1); */
-
     xmlnode_set_attrib(acc, "id", id);
 
     p_node = xmlnode_new_child(acc, "protocol");
@@ -232,17 +234,8 @@
   else{
 
     plugin_xml = xmlnode_new("plugin");
-
     xmlnode_set_attrib(plugin_xml, "id", plugin_id);
-
-    /* p_id = xmlnode_new_child(plugin_xml, "id"); */
-    /* xmlnode_insert_data(p_id, plugin_id, -1); */
-
     data = xmlnode_to_str(plugin_xml, NULL);
-
-    /* purple_debug_info("STATS", "PLGN %s %s\\n", */
-    /*     plugin_id, data); */
-
     g_hash_table_insert(stats_plugins_ht, (void *)plugin_id, (void *)data);
 
   }
@@ -304,16 +297,6 @@
 
     }
 
-    /* g_hash_table_iter_init(&iter, stats_acc_ht); */
-
-    /* while(g_hash_table_iter_next(&iter, &key, &value)){ */
-
-    /*   purple_debug_info("STATS", "HASH %s\\n", value); */
-
-    /* } */
-
-
-    start = xmlnode_get_child(stats_acc_xml, "plugin");
 
     for(;start;start = xmlnode_get_next_twin(start)){
 



More information about the Commits mailing list