/soc/2012/sanket/statscollector-2.x.y: 057b4c91879d: Add OS and ...

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


Changeset: 057b4c91879dcd964f26faf8e9b16a2d46d748a4
Author:	 Sanket Agarwal <sanket at soc.pidgin.im>
Date:	 2012-05-15 07:42 +0000
Branch:	 soc.2012.statscollector
URL: http://hg.pidgin.im/soc/2012/sanket/statscollector-2.x.y/rev/057b4c91879d

Description:

Add OS and Architecture info to XML

TODO: We need to still consider the case when the system architecture is
different from application architecture.

diffstat:

 pidgin/plugins/statscollector.c |  53 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 51 insertions(+), 2 deletions(-)

diffs (81 lines):

diff --git a/pidgin/plugins/statscollector.c b/pidgin/plugins/statscollector.c
--- a/pidgin/plugins/statscollector.c
+++ b/pidgin/plugins/statscollector.c
@@ -23,6 +23,8 @@
 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 @@
 
   /* 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 @@
 
   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