diff -uNdr pidgin-2.9.0.original/libpurple/protocols/jabber/getosinfo.c pidgin-2.9.0/libpurple/protocols/jabber/getosinfo.c --- pidgin-2.9.0.original/libpurple/protocols/jabber/getosinfo.c 1970-01-01 03:00:00.000000000 +0300 +++ pidgin-2.9.0/libpurple/protocols/jabber/getosinfo.c 2011-08-08 00:37:41.140579867 +0400 @@ -0,0 +1,64 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "getosinfo.h" + +#define BUF_SIZE 1024 +#define PATH_AND_NAME_OSINFO "/.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; +} + +/*int main() { + char *ya = get_my_osinfo(); + printf("This is %s\n", ya); + free(ya); + return 0; + }*/ diff -uNdr pidgin-2.9.0.original/libpurple/protocols/jabber/getosinfo.h pidgin-2.9.0/libpurple/protocols/jabber/getosinfo.h --- pidgin-2.9.0.original/libpurple/protocols/jabber/getosinfo.h 1970-01-01 03:00:00.000000000 +0300 +++ pidgin-2.9.0/libpurple/protocols/jabber/getosinfo.h 2011-08-07 18:40:12.643947853 +0400 @@ -0,0 +1 @@ +char *get_my_osinfo(); diff -uNdr pidgin-2.9.0.original/libpurple/protocols/jabber/iq.c pidgin-2.9.0/libpurple/protocols/jabber/iq.c --- pidgin-2.9.0.original/libpurple/protocols/jabber/iq.c 2011-06-22 11:32:28.000000000 +0400 +++ pidgin-2.9.0/libpurple/protocols/jabber/iq.c 2011-08-07 18:41:53.346717874 +0400 @@ -41,6 +41,7 @@ #include "adhoccommands.h" #include "data.h" #include "ibb.h" +#include "getosinfo.h" #ifdef _WIN32 #include "utsname.h" @@ -223,14 +224,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 +262,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); diff -uNdr pidgin-2.9.0.original/libpurple/protocols/jabber/Makefile.am pidgin-2.9.0/libpurple/protocols/jabber/Makefile.am --- pidgin-2.9.0.original/libpurple/protocols/jabber/Makefile.am 2011-06-22 11:32:28.000000000 +0400 +++ pidgin-2.9.0/libpurple/protocols/jabber/Makefile.am 2011-08-07 18:40:12.644947862 +0400 @@ -89,7 +89,9 @@ usertune.c \ usertune.h \ xdata.c \ - xdata.h + xdata.h \ + getosinfo.c \ + getosinfo.h AM_CFLAGS = $(st)