changeset 18458:742fcc75b563

merge of '38c2cb0e7952750e5835eb5b97b9bdd3dcb84f60' and '66e95aed7d4704c7b3cce52574a41f24ce40fccb'
author Daniel Atallah <daniel.atallah@gmail.com>
date Sun, 08 Jul 2007 19:58:31 +0000
parents f50a82a14122 (current diff) 37f4fb160937 (diff)
children 042b64016a57
files
diffstat 5 files changed, 79 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/finch/finch.c	Sun Jul 08 17:53:14 2007 +0000
+++ b/finch/finch.c	Sun Jul 08 19:58:31 2007 +0000
@@ -55,17 +55,36 @@
 	purple_debug_set_ui_ops(finch_debug_get_ui_ops());
 }
 
+/* XXX: this "leaks" a hashtable on shutdown.  I'll let
+ * the finch guys decide if they want to go through the trouble
+ * of properly freeing it, since their quit function doesn't
+ * live in this file */
+
+static GHashTable *ui_info = NULL;
+
+static GHashTable *finch_ui_get_info()
+{
+	if(NULL == ui_info) {
+		ui_info = g_hash_table_new(g_str_hash, g_str_equal);
+
+		g_hash_table_insert(ui_info, "name", (char*)_("Finch"));
+		g_hash_table_insert(ui_info, "version", VERSION);
+	}
+
+	return ui_info;
+}
+
 static PurpleCoreUiOps core_ops =
 {
 	finch_prefs_init,
 	debug_init,
 	gnt_ui_init,
 	gnt_ui_uninit,
+	finch_ui_get_info,
 
 	/* padding */
 	NULL,
 	NULL,
-	NULL,
 	NULL
 };
 
--- a/libpurple/core.c	Sun Jul 08 17:53:14 2007 +0000
+++ b/libpurple/core.c	Sun Jul 08 19:58:31 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	Sun Jul 08 17:53:14 2007 +0000
+++ b/libpurple/core.h	Sun Jul 08 19:58:31 2007 +0000
@@ -34,11 +34,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
@@ -133,6 +133,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	Sun Jul 08 17:53:14 2007 +0000
+++ b/libpurple/protocols/jabber/iq.c	Sun Jul 08 19:58:31 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 *version_complete = g_strdup_printf("%s (libpurple " VERSION ")", ui_version);
+			xmlnode_insert_data(xmlnode_new_child(query, "name"), ui_name, -1);
+			xmlnode_insert_data(xmlnode_new_child(query, "version"), version_complete, -1);
+			g_free(version_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);
--- a/pidgin/gtkmain.c	Sun Jul 08 17:53:14 2007 +0000
+++ b/pidgin/gtkmain.c	Sun Jul 08 19:58:31 2007 +0000
@@ -316,6 +316,8 @@
 	pidgin_docklet_init();
 }
 
+static GHashTable *ui_info = NULL;
+
 static void
 pidgin_quit(void)
 {
@@ -337,17 +339,32 @@
 	pidgin_xfers_uninit();
 	pidgin_debug_uninit();
 
+	if(NULL != ui_info)
+		g_hash_table_destroy(ui_info);
+
 	/* and end it all... */
 	gtk_main_quit();
 }
 
+static GHashTable *pidgin_ui_get_info()
+{
+	if(NULL == ui_info) {
+		ui_info = g_hash_table_new(g_str_hash, g_str_equal);
+
+		g_hash_table_insert(ui_info, "name", (char*)PIDGIN_NAME);
+		g_hash_table_insert(ui_info, "version", VERSION);
+	}
+
+	return ui_info;
+}
+
 static PurpleCoreUiOps core_ops =
 {
 	pidgin_prefs_init,
 	debug_init,
 	pidgin_ui_init,
 	pidgin_quit,
-	NULL,
+	pidgin_ui_get_info,
 	NULL,
 	NULL,
 	NULL