soc.2012.statscollector: b2e6ddd9: Add OS and Architecture info to XML
sanket at soc.pidgin.im
sanket at soc.pidgin.im
Tue May 15 22:46:03 EDT 2012
----------------------------------------------------------------------
Revision: b2e6ddd92a0b541f8ad099f1af2742504c7d591f
Parent: 7132748e762d1c1ea8a44e67181eda069f9454fc
Author: sanket at soc.pidgin.im
Date: 05/15/12 03:42:31
Branch: im.pidgin.soc.2012.statscollector
URL: http://d.pidgin.im/viewmtn/revision/info/b2e6ddd92a0b541f8ad099f1af2742504c7d591f
Changelog:
Add OS and Architecture info to XML
TODO: We need to still consider the case when the system architecture is
different from application architecture.
Changes against parent 7132748e762d1c1ea8a44e67181eda069f9454fc
patched pidgin/plugins/statscollector.c
-------------- next part --------------
============================================================
--- pidgin/plugins/statscollector.c ce362251cdab5bddd72081b8987b79356dd51c71
+++ pidgin/plugins/statscollector.c aad6a454e319ed1355fcd6f80d2169cb30d1a73c
@@ -23,6 +23,8 @@ int save_timer = 0;
GHashTable *stats_acc_ht, *stats_plugins_ht;
int save_timer = 0;
+enum OS_TYPES {WINDOWS, APPLE, UNIX};
+
static void
save_xml(){
@@ -88,12 +90,57 @@ get_cpuinfo_xml(){
/* Obtains a XML node containing the CPU info */
- xmlnode *root, *languages, *node, *ver;
+ xmlnode *root, *languages, *node, *ver, *os, *cpu, *native_arch, *app_arch;
const char * const * langs;
- int i;
+ char *str_os, *str_native_arch, *str_app_arch;
+ int i, app_bs, native_bs;
+ enum OS_TYPES e_os;
root = xmlnode_new("cpuinfo");
+ /* CPU os/hw info */
+
+ cpu = xmlnode_new("cpu");
+ xmlnode_insert_child(root, cpu);
+
+ /* Base OS */
+
+ os = xmlnode_new("os");
+
+#ifdef _WIN32
+ e_os = WINDOWS;
+#elif defined __APPLE__
+ e_os = APPLE;
+#elif defined __unix__
+ e_os = UNIX;
+#endif
+
+ switch(e_os){
+
+ case WINDOWS:
+ str_os = g_strdup("WINDOWS");
+ case APPLE:
+ str_os = g_strdup("APPLE");
+ case UNIX:
+ str_os = g_strdup("UNIX");
+
+ }
+
+ xmlnode_insert_data(os, str_os, -1);
+ xmlnode_insert_child(cpu, os);
+
+ /* Application arch */
+
+ app_arch = xmlnode_new("app-arch");
+
+ app_bs = sizeof(int)*8;
+ if(app_bs==32) str_app_arch = g_strdup("32");
+ else if(app_bs==64) str_app_arch = g_strdup("64");
+ purple_debug_info("STATS", "ARCH SIZE: %d\n", app_bs);
+
+ xmlnode_insert_data(app_arch, str_app_arch, -1);
+ xmlnode_insert_child(cpu, app_arch);
+
/* Languages */
langs = g_get_language_names();
@@ -273,6 +320,8 @@ init_stats(){
if(!root){
+ /* Reset the XML if it does not exist or is corrupt */
+
purple_debug_info("STATS", "failed to load stats.xml");
/* Populate CPU info only on start as this will not change often */
More information about the Commits
mailing list