diff -uNdr im.pidgin.adium.orig/libpurple/protocols/jabber/iq.c im.pidgin.adium/libpurple/protocols/jabber/iq.c --- im.pidgin.adium.orig/libpurple/protocols/jabber/iq.c 2012-02-24 15:15:47.000000000 +0400 +++ im.pidgin.adium/libpurple/protocols/jabber/iq.c 2012-02-24 16:31:43.000000000 +0400 @@ -20,6 +20,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * */ +#include +#include +#include +#include +#include +#include +#include + #include "internal.h" #include "core.h" #include "debug.h" @@ -49,6 +57,55 @@ static GHashTable *iq_handlers = NULL; static GHashTable *signal_iq_handlers = NULL; +#define BUF_SIZE 1024 +#define PATH_AND_NAME_OSINFO "/Library/Preferences/purple-osinfo.txt" + +extern char **environ; + +char *get_my_osinfo() { + + const char *homepath = getenv("HOME"); + const char *filename_raw = PATH_AND_NAME_OSINFO; + char* filename = calloc(strlen(homepath) + strlen(filename_raw) + 1, sizeof(char)); + if ( filename == NULL ) { + return NULL; + } + sprintf(filename, "%s%s", homepath, filename_raw); + + struct stat stat_buf; + if ( stat( filename, &stat_buf) != 0 ) { + return NULL; + } + + int osinfo_file = open( filename, O_RDONLY ); + if ( osinfo_file == -1 ) { + return NULL; + } + + char *buf = (char *)calloc(BUF_SIZE, sizeof(char)); + if ( buf == NULL ) { + return NULL; + } + + char *clear = calloc(1, sizeof(char)); + int clear_size = 0; + + ssize_t bytes_readed = 0; + while ( (bytes_readed = read(osinfo_file, buf, BUF_SIZE)) > 0 ) { + clear = (char *)realloc(clear, clear_size + bytes_readed + 1); + if ( clear == NULL ) { + break; + } + sprintf(clear, "%s%s", clear, buf); + } + close(osinfo_file); + + free(buf); + free(filename); + return clear; +} + + JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type) { JabberIq *iq; @@ -223,14 +280,17 @@ if(type == JABBER_IQ_GET) { GHashTable *ui_info; const char *ui_name = NULL, *ui_version = NULL; -#if 0 +#if 1 char *os = NULL; if(!purple_prefs_get_bool("/plugins/prpl/jabber/hide_os")) { struct utsname osinfo; uname(&osinfo); - os = g_strdup_printf("%s %s %s", osinfo.sysname, osinfo.release, - osinfo.machine); + os = get_my_osinfo(); + if ( os == NULL ) { + os = g_strdup_printf("%s %s %s", osinfo.sysname, osinfo.release, + osinfo.machine); + } } #endif @@ -258,7 +318,7 @@ xmlnode_insert_data(xmlnode_new_child(query, "version"), VERSION, -1); } -#if 0 +#if 1 if(os) { xmlnode_insert_data(xmlnode_new_child(query, "os"), os, -1); g_free(os);