/soc/2012/sanket/statscollector-2.x.y: 4d52e64aec1d: Spacing mod...
Sanket Agarwal
sanket at soc.pidgin.im
Sun Mar 31 00:37:39 EDT 2013
Changeset: 4d52e64aec1dd2412c027fdb3767c66149753cba
Author: Sanket Agarwal <sanket at soc.pidgin.im>
Date: 2013-03-30 20:24 +0530
Branch: soc.2012.statscollector
URL: https://hg.pidgin.im/soc/2012/sanket/statscollector-2.x.y/rev/4d52e64aec1d
Description:
Spacing modifications.
diffstat:
libpurple/plugins/statscollector.c | 176 ++++++++++--------------------------
1 files changed, 52 insertions(+), 124 deletions(-)
diffs (truncated from 538 to 300 lines):
diff --git a/libpurple/plugins/statscollector.c b/libpurple/plugins/statscollector.c
--- a/libpurple/plugins/statscollector.c
+++ b/libpurple/plugins/statscollector.c
@@ -84,47 +84,37 @@ static void acc_sign_on_event(PurpleAcco
static void
confirm_allow(){
-
/* Set the allow variable in prefs to ALLOW */
purple_prefs_set_int("/plugins/core/statscollector/allow", ALLOW);
-
}
static void
confirm_deny(){
-
/* Set the allow variable in prefs to ALLOW */
purple_prefs_set_int("/plugins/core/statscollector/allow", DENY);
-
}
static void
confirm_later(){
-
/* No-op right now, but can contain logic wherein we have
* a timeout before the next callout for authorize/deny
*/
-
}
static glong
get_time_sec(){
-
/* Gets current time in seconds */
GTimeVal res;
g_get_current_time(&res);
return res.tv_sec;
-
}
static void
save_xml(){
-
/* Uses the Hash tables and other XML nodes
* that have been saved/modified and create
* final modified XML out of it to be flushed
*/
-
GHashTableIter iter;
gpointer key, value;
xmlnode *nroot, *nacc, *nplugins, *nuis;
@@ -147,22 +137,15 @@ save_xml(){
nuis = xmlnode_new_child(nroot, "uis");
/* Use the hash tables to populate acc and plugins */
-
g_hash_table_iter_init(&iter, stats_acc_ht);
-
while(g_hash_table_iter_next(&iter, &key, &value)){
xmlnode_insert_child(nacc, xmlnode_copy((xmlnode *)value));
}
-
-
g_hash_table_iter_init(&iter, stats_plugins_ht);
-
while(g_hash_table_iter_next(&iter, &key, &value)){
xmlnode_insert_child(nplugins, xmlnode_copy((xmlnode *)value));
}
-
g_hash_table_iter_init(&iter, stats_uis_ht);
-
while(g_hash_table_iter_next(&iter, &key, &value)){
xmlnode_insert_child(nuis, xmlnode_copy((xmlnode *)value));
}
@@ -171,7 +154,6 @@ save_xml(){
purple_util_write_data_to_file("stats.xml", data, -1);
xmlnode_free(nroot);
g_free(data);
-
}
static gboolean
@@ -197,30 +179,33 @@ refresh_accounts(){
g_list_foreach(loaded_accounts, (GFunc)acc_sign_on_event, NULL);
}
+/*
+ * Check if the header has HTTP/1.1 200 ...
+ * I am assuming that the first few characters will always follow
+ * the following format:
+ * HTTP/1.x xyz reason
+ */
static void
-refresh_public_server_cache_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message){
-
- /*
- * Check if the header has HTTP/1.1 200 ...
- * I am assuming that the first few characters will always follow
- * the following format:
- * HTTP/1.x xyz reason
- */
-
+refresh_public_server_cache_cb(PurpleUtilFetchUrlData *url_data,
+ gpointer user_data, const gchar *url_text, gsize len,
+ const gchar *error_message)
+{
int code = -1;
char *header = g_strdup_printf("%s", url_text);
char *data_loc=NULL;
const char *hash_id;
xmlnode *public_server_hash_root, *start;
- if(header && strlen(header) >= 14) {
+ if(header && strlen(header) >= 14)
+ {
header += 9;
header[3] = '\0';
code = atoi(header);
}
purple_debug_info("STATS", "Code returned: %d\n", code);
- if(code == 200){
+ if(code == 200)
+ {
/* Extract the data to be converted to XML => GList */
data_loc = strstr(url_text, "\r\n\r\n");
public_server_hash_root = xmlnode_from_str(data_loc, -1);
@@ -230,7 +215,8 @@ refresh_public_server_cache_cb(PurpleUti
* that the server might give away!
*/
start = xmlnode_get_child(public_server_hash_root, "hash");
- for(;start;start = xmlnode_get_next_twin(start)){
+ for(;start;start = xmlnode_get_next_twin(start))
+ {
hash_id = xmlnode_get_attrib(start, "id");
g_hash_table_insert(public_server_cache_ht, (void *)hash_id, NULL);
}
@@ -246,8 +232,8 @@ refresh_public_server_cache_cb(PurpleUti
}
static gboolean
-refresh_public_server_cache(gpointer data){
-
+refresh_public_server_cache(gpointer data)
+{
/* Refresh the stored cache of information about IRC/Jabber
* servers which are in-effect public using md5 hashes!
*/
@@ -271,14 +257,13 @@ refresh_public_server_cache(gpointer dat
g_free(host);
g_free(path);
g_free(request);
+
return FALSE;
-
}
+/* Determines if the application is running in 32 or 64 bit mode */
static xmlnode *
get_app_32_64(){
-
- /* Determines if the application is running in 32 or 64 bit mode */
int pt_size;
xmlnode *bit_size_xml;
@@ -286,41 +271,29 @@ get_app_32_64(){
bit_size_xml = xmlnode_new("app-bit");
xmlnode_insert_data(bit_size_xml, g_strdup_printf("%d",pt_size), -1);
return bit_size_xml;
-
}
+/* Determines whether the kernel we are running is 32 or 64 bit */
static xmlnode *
get_os_32_64(){
-
- /* Determines whether the kernel we are running is 32 or 64 bit */
int bit_size=-1;
xmlnode *bit_size_xml;
#ifdef _WIN32
-
BOOL bIsWow64;
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
LPFN_ISWOW64PROCESS fnIsWow64Process;
-
#elif defined _POSIX_VERSION
-
struct utsname os_utsname;
char *m_name, *bit_size_str;
-
#endif
-
bit_size_xml = xmlnode_new("os-bit");
-
#ifdef _WIN64
-
bit_size = 64;
-
#elif defined _WIN32
-
/* Check if we are running as wow64 process */
bIsWow64 = FALSE;
fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress( \
GetModuleHandle(TEXT("kernel32")),"IsWow64Process");
-
if(NULL != fnIsWow64Process)
{
if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64))
@@ -330,22 +303,17 @@ get_os_32_64(){
}
if(bIsWow64) bit_size= 64;
else bit_size = 32;
-
#elif _POSIX_VERSION
-
/* Use uname to find kernel architecture and infer bit-size */
uname(&os_utsname);
m_name = os_utsname.machine;
-
/* Identifying 64 bit OS is tricky. We use the following identifiers
* on basis of experience with uname(2) call.
*/
-
if(!g_strcmp0(m_name, "x86_64") || !g_strcmp0(m_name, "ia64") \
|| !g_strcmp0(m_name, "amd64") || !g_strcmp0(m_name, "ppc64")) \
bit_size = 64;
else bit_size = 32;
-
#endif
bit_size_str = g_strdup_printf("%d", bit_size);
@@ -355,14 +323,12 @@ get_os_32_64(){
g_free(bit_size_str);
return bit_size_xml;
-
}
static xmlnode *
-get_arch(){
-
+get_arch()
+{
/* Obtains the architecture type */
-
xmlnode *arch_xml;
char *arch_str;
@@ -376,12 +342,9 @@ get_arch(){
#endif
arch_xml = xmlnode_new("arch");
-
-
#ifdef _WIN32
pGNSI = (PGNSI) GetProcAddress(
GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo");
-
if(NULL != pGNSI)
pGNSI(&sys_info);
else GetSystemInfo(&sys_info);
@@ -408,16 +371,14 @@ get_arch(){
xmlnode_set_attrib(arch_xml, "id", arch_str);
return arch_xml;
-
}
+/* Determines the name of the operating system as <os-info id="...">
+ * we could specialize it's name further in this xml
+ */
static xmlnode *
-get_os_name(){
-
- /* Determines the name of the operating system as <os-info id="...">
- * we could specialize it's name further in this xml
- */
-
+get_os_name()
+{
xmlnode *os_name_xml;
char *name_attrib;
@@ -427,14 +388,11 @@ get_os_name(){
OSVERSIONINFO osvi;
#elif defined __APPLE__
-
int mib[2];
size_t length;
SInt32 major_version,minor_version,bug_fix_version;
-
char sys_ver_file[] = "/System/Library/CoreServices/SystemVersion.plist";
char *sys_ver_contents, *key_str, *value_str;
-
GHashTable *sys_ver_ht;
GError *err;
xmlnode *product_version_xml;
@@ -448,17 +406,13 @@ get_os_name(){
More information about the Commits
mailing list