# HG changeset patch # User Sadrul Habib Chowdhury # Date 1215042659 0 # Node ID b5f679e956660c41d19ab734860a499d956e2326 # Parent 3c2963654752f627582303e620fb9c197b15b955 cmd-added and cmd-removed signals to emit when commands are registered/unregistered. diff -r 3c2963654752 -r b5f679e95666 ChangeLog.API --- a/ChangeLog.API Wed Jul 02 16:54:03 2008 +0000 +++ b/ChangeLog.API Wed Jul 02 23:50:59 2008 +0000 @@ -18,6 +18,8 @@ * 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 diff -r 3c2963654752 -r b5f679e95666 libpurple/cmds.c --- a/libpurple/cmds.c Wed Jul 02 16:54:03 2008 +0000 +++ b/libpurple/cmds.c Wed Jul 02 23:50:59 2008 +0000 @@ -81,6 +81,8 @@ 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 @@ 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 @@ 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()); +} + diff -r 3c2963654752 -r b5f679e95666 libpurple/cmds.h --- a/libpurple/cmds.h Wed Jul 02 16:54:03 2008 +0000 +++ b/libpurple/cmds.h Wed Jul 02 23:50:59 2008 +0000 @@ -1,6 +1,7 @@ /** * @file cmds.h Commands API * @ingroup core + * @see @ref cmd-signals */ /* Copyright (C) 2003 Timothy Ringenbach @@ -221,6 +222,25 @@ */ 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 diff -r 3c2963654752 -r b5f679e95666 libpurple/core.c --- a/libpurple/core.c Wed Jul 02 16:54:03 2008 +0000 +++ b/libpurple/core.c Wed Jul 02 23:50:59 2008 +0000 @@ -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_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_connections_disconnect_all(); /* Save .xml files, remove signals, etc. */ + purple_cmds_uninit(); purple_smileys_uninit(); purple_idle_uninit(); purple_ssl_uninit();