pidgin: 2f874867: cmd-added and cmd-removed signals to emi...

sadrul at pidgin.im sadrul at pidgin.im
Wed Jul 2 20:00:40 EDT 2008


-----------------------------------------------------------------
Revision: 2f8748670d99df0274b367a89aa1bdffbd814226
Ancestor: 7d7cad21b9890db77aa52c376608a03195bb5c7d
Author: sadrul at pidgin.im
Date: 2008-07-02T23:50:59
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/2f8748670d99df0274b367a89aa1bdffbd814226

Modified files:
        ChangeLog.API libpurple/cmds.c libpurple/cmds.h
        libpurple/core.c

ChangeLog: 

cmd-added and cmd-removed signals to emit when commands are registered/unregistered.

-------------- next part --------------
============================================================
--- ChangeLog.API	56a0133e9560f61a6a3bf4e3894baea9390c21dd
+++ ChangeLog.API	6032dd75aa2952fdf713d5779d7f1bd9b7b89750
@@ -18,6 +18,8 @@ version 2.5.0 (??/??/2008):
 		* purple_notify_user_info_prepend_section_break
 		* purple_notify_user_info_prepend_section_header
 		* "website" and "dev_website" items to the ui_info hash table
+		* purple_cmds_get_handle, purple_cmds_init, purple_cmds_uninit
+		* cmd-added and cmd-removed signals
 
 		Deprecated:
 		* purple_blist_update_buddy_icon
============================================================
--- libpurple/cmds.c	f001eeb47fb6e699156f6623cb0545705508b287
+++ libpurple/cmds.c	d7e728f8d66b98344fa230141a50c183bed3d6a9
@@ -81,6 +81,8 @@ PurpleCmdId purple_cmd_register(const gc
 
 	cmds = g_list_insert_sorted(cmds, c, (GCompareFunc)cmds_compare_func);
 
+	purple_signal_emit(purple_cmds_get_handle(), "cmd-added", cmd, p, f);
+
 	return id;
 }
 
@@ -103,6 +105,7 @@ void purple_cmd_unregister(PurpleCmdId i
 
 		if (c->id == id) {
 			cmds = g_list_remove(cmds, c);
+			purple_signal_emit(purple_cmds_get_handle(), "cmd-removed", c->cmd);
 			purple_cmd_free(c);
 			return;
 		}
@@ -361,3 +364,28 @@ GList *purple_cmd_help(PurpleConversatio
 	return ret;
 }
 
+gpointer purple_cmds_get_handle(void)
+{
+	static int handle;
+	return &handle;
+}
+
+void purple_cmds_init(void)
+{
+	gpointer handle = purple_cmds_get_handle();
+
+	purple_signal_register(handle, "cmd-added",
+			purple_marshal_VOID__POINTER_INT_INT, NULL, 3,
+			purple_value_new(PURPLE_TYPE_STRING),
+			purple_value_new(PURPLE_TYPE_INT),
+			purple_value_new(PURPLE_TYPE_INT));
+	purple_signal_register(handle, "cmd-removed",
+			purple_marshal_VOID__POINTER, NULL, 1,
+			purple_value_new(PURPLE_TYPE_STRING));
+}
+
+void purple_cmds_uninit(void)
+{
+	purple_signals_unregister_by_instance(purple_cmds_get_handle());
+}
+
============================================================
--- libpurple/cmds.h	877e4437774d5a1cd82e07e462e55ede50d9edd2
+++ libpurple/cmds.h	033a4a99a2f13b5cf8fced0037a1dbb81b4c169b
@@ -1,6 +1,7 @@
 /**
  * @file cmds.h Commands API
  * @ingroup core
+ * @see @ref cmd-signals
  */
 
 /* Copyright (C) 2003 Timothy Ringenbach <omarvo at hotmail.com>
@@ -221,6 +222,25 @@ GList *purple_cmd_help(PurpleConversatio
  */
 GList *purple_cmd_help(PurpleConversation *conv, const gchar *cmd);
 
+/**
+ * Get the handle for the commands API
+ * @return The handle
+ * @since 2.5.0
+ */
+gpointer purple_cmds_get_handle(void);
+
+/**
+ * Initialize the commands subsystem.
+ * @since 2.5.0
+ */
+void purple_cmds_init(void);
+
+/**
+ * Uninitialize the commands subsystem.
+ * @since 2.5.0
+ */
+void purple_cmds_uninit(void);
+
 /*@}*/
 
 #ifdef __cplusplus
============================================================
--- libpurple/core.c	0086adbca66e71ab77f59508b10b2c54c03a69c0
+++ libpurple/core.c	14ae09df76080254e1d9f8ebcccffbf54525a828
@@ -26,6 +26,7 @@
 #include "internal.h"
 #include "cipher.h"
 #include "certificate.h"
+#include "cmds.h"
 #include "connection.h"
 #include "conversation.h"
 #include "core.h"
@@ -169,6 +170,7 @@ purple_core_init(const char *ui)
 	purple_xfers_init();
 	purple_idle_init();
 	purple_smileys_init();
+	purple_cmds_init();
 
 	/*
 	 * Call this early on to try to auto-detect our IP address and
@@ -197,6 +199,7 @@ purple_core_quit(void)
 	purple_connections_disconnect_all();
 
 	/* Save .xml files, remove signals, etc. */
+	purple_cmds_uninit();
 	purple_smileys_uninit();
 	purple_idle_uninit();
 	purple_ssl_uninit();


More information about the Commits mailing list