changeset 18456:0e8b2bb66a7d

merge of '54ca7908e9d5ca615490f92be7a4be6bdf9d9baa' and '6fa4458c20080f2ce1f66a6ee4761c192b8510d5'
author Nathan Walp <nwalp@pidgin.im>
date Tue, 03 Jul 2007 12:12:33 +0000
parents be8c4eba38f6 (current diff) c58b83d2b188 (diff)
children 37f4fb160937
files finch/finch.c libpurple/core.h pidgin/gtkdocklet.c pidgin/gtkmain.c
diffstat 5 files changed, 79 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/finch/finch.c	Tue Jul 03 11:20:33 2007 +0000
+++ b/finch/finch.c	Tue Jul 03 12:12:33 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	Tue Jul 03 11:20:33 2007 +0000
+++ b/libpurple/core.c	Tue Jul 03 12:12:33 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	Tue Jul 03 11:20:33 2007 +0000
+++ b/libpurple/core.h	Tue Jul 03 12:12:33 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	Tue Jul 03 11:20:33 2007 +0000
+++ b/libpurple/protocols/jabber/iq.c	Tue Jul 03 12:12:33 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	Tue Jul 03 11:20:33 2007 +0000
+++ b/pidgin/gtkmain.c	Tue Jul 03 12:12:33 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