/soc/2012/sanket/statscollector-2.x.y: 5defe53326d5: Add ``user_...
Sanket Agarwal
sanket at soc.pidgin.im
Tue Jul 10 00:36:27 EDT 2012
Changeset: 5defe53326d5baaa12bf0691d60f7ff1b0deb28e
Author: Sanket Agarwal <sanket at soc.pidgin.im>
Date: 2012-06-06 19:42 +0000
Branch: soc.2012.statscollector
URL: http://hg.pidgin.im/soc/2012/sanket/statscollector-2.x.y/rev/5defe53326d5
Description:
Add ``user_splits'' information for accounts
A typical jabber account can split to username at domain/resource and IRC account
to username at domain but to do such splits in general (for example prpl-yahoo does
not have any splits) we need to use user_splits which tells us which parts mean
what. This way we can use non-sensitive data to be sent along-with other stats
and classify the accounts further on basis of Facebook or Gtalk.
There's a additional bit of information in the form of ``connect-server'' which
is valid only for XMPP accounts and I have added that too as domains are not
authoritative in classifying the XMPP/Jabber service provider for the domain.
Finally, there are some warning-fixes but I felt too lazy to get them in
another patch, so they are attached inline.
diffstat:
libpurple/plugins/statscollector.c | 86 +++++++++++++++++++++++++++++++++++--
1 files changed, 80 insertions(+), 6 deletions(-)
diffs (132 lines):
diff --git a/libpurple/plugins/statscollector.c b/libpurple/plugins/statscollector.c
--- a/libpurple/plugins/statscollector.c
+++ b/libpurple/plugins/statscollector.c
@@ -12,6 +12,7 @@
#include "cipher.h"
#include "prpl.h"
#include "core.h"
+#include "accountopt.h"
#include <glib.h>
/* #include <gtkplugin.h> */
@@ -56,7 +57,7 @@
enum OS_TYPES {WINDOWS, APPLE, UNIX};
enum BIT_32_64 {BIT_32, BIT_64};
-static void schedule_send();
+static void schedule_send(void);
static gboolean send_stats();
static glong
@@ -604,18 +605,26 @@
* 1.1 If no, then add the account to the list of accounts used
*/
- const char *username, *protocol, *data;
- char *id;
- xmlnode *acc, *p_node, *len_node;
+ const char *username, *protocol, *data, *connect_server="";
+ char *id, *username_dup;
+ xmlnode *acc, *p_node, *len_node, *connect_server_node;
int len;
+ PurplePlugin *prpl_plugin;
+ PurplePluginProtocolInfo *prpl_info;
+ GList *user_splits, *l, *l2;
username = purple_account_get_username(account);
protocol = purple_account_get_protocol_id(account);
+ if(username==NULL || protocol==NULL) return;
+ if(!(prpl_plugin = purple_find_prpl(protocol))) return;
+
+ if(!(prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl_plugin))) return;
+ user_splits = prpl_info->user_splits;
+
id = get_acc_id(username, protocol);
/* check if the account already exist in our XML file */
-
if(g_hash_table_lookup(stats_acc_ht, id))
purple_debug_info("STATS", "Account already exists!");
else{
@@ -634,6 +643,70 @@
xmlnode_insert_data(len_node, g_strdup_printf("%d", len), -1);
xmlnode_insert_child(acc, len_node);
+ /* We can also send ``username-splits'' as they will be helpful
+ * in general
+ */
+ l2 = NULL;
+ username_dup = g_strdup(username);
+
+ if(user_splits != NULL){
+
+ for (l = g_list_last(user_splits);l != NULL;l = l->prev) {
+
+ PurpleAccountUserSplit *split = l->data;
+ const char *value = NULL;
+ char *c;
+ xmlnode *user_split_node;
+
+ if(purple_account_user_split_get_reverse(split))
+ c = strrchr(username_dup,
+ purple_account_user_split_get_separator(split));
+ else
+ c = strchr(username_dup,
+ purple_account_user_split_get_separator(split));
+
+ if (c != NULL) {
+ *c = '\0';
+ c++;
+ value = c;
+ }
+
+ if (value == NULL)
+ value = "";
+
+ user_split_node = xmlnode_new(split->text);
+ xmlnode_insert_data(user_split_node, value, -1);
+ xmlnode_insert_child(acc, user_split_node);
+ }
+
+ }
+
+
+ /* Server information if Jabber */
+ if(!g_strcmp0(protocol,"prpl-jabber")){
+
+ /* Connect server is helpful in cases when the talk server
+ * is different from domain. Eg, x at mydomain.com could be
+ * registered with google apps and hence use talk.google.com
+ * instead as it's chat server
+ */
+
+ connect_server = purple_account_get_string(account, "connect_server", "");
+ connect_server_node = xmlnode_new("connect-server");
+ xmlnode_insert_data(connect_server_node, connect_server, -1);
+ xmlnode_insert_child(acc, connect_server_node);
+
+
+ }
+
+ user_splits = PURPLE_PLUGIN_PROTOCOL_INFO(purple_find_prpl \
+ (purple_account_get_protocol_id(account)))->user_splits;
+
+ if(user_splits != NULL){
+
+ }
+
+
data = xmlnode_to_str(acc, NULL);
g_hash_table_insert(stats_acc_ht, (void *)id, (void *)data);
@@ -702,7 +775,8 @@
PurpleUtilFetchUrlData *urldata;
gchar *host, *path, *request, *filename, *url= SEND_URL;
- gchar *pd_xml, *pd_id, *postdata;
+ gchar *pd_xml, *postdata;
+ const char *pd_id;
GError *error;
int port;
gsize length;
More information about the Commits
mailing list