Mercurial > pidgin
changeset 18292:9db52d9b8436
core support for UI info...now to do the UI piece
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Mon, 02 Jul 2007 03:26:08 +0000 |
parents | 51ebbe199514 |
children | 5aae8608e1c6 |
files | libpurple/core.c libpurple/core.h libpurple/protocols/jabber/iq.c |
diffstat | 3 files changed, 41 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/core.c Mon Jun 25 17:44:40 2007 +0000 +++ b/libpurple/core.c Mon Jul 02 03:26:08 2007 +0000 @@ -764,3 +764,12 @@ g_free(status_file); return TRUE; } + +GHashTable* purple_core_get_ui_info() { + PurpleCoreUiOps *ops = purple_core_get_ui_ops(); + + if(NULL == ops || NULL == ops->get_ui_info) + return NULL; + + return ops->get_ui_info(); +}
--- a/libpurple/core.h Mon Jun 25 17:44:40 2007 +0000 +++ b/libpurple/core.h Mon Jul 02 03:26:08 2007 +0000 @@ -32,11 +32,11 @@ void (*debug_ui_init)(void); /* Unfortunate necessity. */ void (*ui_init)(void); void (*quit)(void); + GHashTable* (*get_ui_info)(void); void (*_purple_reserved1)(void); void (*_purple_reserved2)(void); void (*_purple_reserved3)(void); - void (*_purple_reserved4)(void); } PurpleCoreUiOps; #ifdef __cplusplus @@ -131,6 +131,17 @@ */ gboolean purple_core_ensure_single_instance(void); +/** + * Returns a hashtable containing various information about the UI + * + * @return A GHashTable with strings for keys and values. This + * hash table must not be freed. + * + * @since 2.1.0 + * + */ +GHashTable* purple_core_get_ui_info(void); + #ifdef __cplusplus } #endif
--- a/libpurple/protocols/jabber/iq.c Mon Jun 25 17:44:40 2007 +0000 +++ b/libpurple/protocols/jabber/iq.c Mon Jul 02 03:26:08 2007 +0000 @@ -19,6 +19,7 @@ * */ #include "internal.h" +#include "core.h" #include "debug.h" #include "prefs.h" #include "util.h" @@ -250,6 +251,8 @@ type = xmlnode_get_attrib(packet, "type"); if(type && !strcmp(type, "get")) { + GHashTable *ui_info; + const char *ui_name = NULL, *ui_version = NULL; if(!purple_prefs_get_bool("/plugins/prpl/jabber/hide_os")) { struct utsname osinfo; @@ -268,9 +271,23 @@ query = xmlnode_get_child(iq->node, "query"); - /* TODO: ask the core for the version of libpurple and the name and version of the UI */ - xmlnode_insert_data(xmlnode_new_child(query, "name"), "libpurple", -1); - xmlnode_insert_data(xmlnode_new_child(query, "version"), VERSION, -1); + ui_info = purple_core_get_ui_info(); + + if(NULL != ui_info) { + ui_name = g_hash_table_lookup(ui_info, "name"); + ui_version = g_hash_table_lookup(ui_info, "version"); + } + + if(NULL != ui_name && NULL != ui_version) { + char *name_complete = g_strdup_printf("%s (libpurple " VERSION ")", ui_name); + xmlnode_insert_data(xmlnode_new_child(query, "name"), name_complete, -1); + xmlnode_insert_data(xmlnode_new_child(query, "version"), ui_version, -1); + g_free(name_complete); + } else { + xmlnode_insert_data(xmlnode_new_child(query, "name"), "libpurple", -1); + xmlnode_insert_data(xmlnode_new_child(query, "version"), VERSION, -1); + } + if(os) { xmlnode_insert_data(xmlnode_new_child(query, "os"), os, -1); g_free(os);