From: <the...@us...> - 2006-07-17 06:21:55
|
Revision: 16505 Author: thekingant Date: 2006-07-16 23:21:53 -0700 (Sun, 16 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16505&view=rev Log Message: ----------- Change the music messaging plugin to not try to load if our D-BUS stuff is not initialized. Also extracted the gaim_notify_error() message code to a #define in src/dbus-server.c And print a debug warning if something tries to register a callback for a signal using a handle that we don't have any registered signals for Modified Paths: -------------- trunk/plugins/dbus-example.c trunk/plugins/musicmessaging/musicmessaging.c trunk/src/dbus-server.h trunk/src/signals.c Modified: trunk/plugins/dbus-example.c =================================================================== --- trunk/plugins/dbus-example.c 2006-07-17 05:50:49 UTC (rev 16504) +++ trunk/plugins/dbus-example.c 2006-07-17 06:21:53 UTC (rev 16505) @@ -109,17 +109,8 @@ static gboolean plugin_load(GaimPlugin *plugin) { - const char *dbus_init_error; + GAIM_DBUS_RETURN_FALSE_IF_DISABLED(plugin); - dbus_init_error = gaim_dbus_get_init_error(); - if (dbus_init_error != NULL) - { - gaim_notify_error(NULL, _("Unable to Load Plugin"), - _("Gaim's D-BUS server is not running for the reason listed below"), - _(dbus_init_error)); - return FALSE; - } - /* First, we have to register our four exported functions with the main gaim dbus loop. Without this statement, the gaim dbus code wouldn't know about our functions. */ Modified: trunk/plugins/musicmessaging/musicmessaging.c =================================================================== --- trunk/plugins/musicmessaging/musicmessaging.c 2006-07-17 05:50:49 UTC (rev 16504) +++ trunk/plugins/musicmessaging/musicmessaging.c 2006-07-17 06:21:53 UTC (rev 16505) @@ -259,6 +259,8 @@ plugin_load(GaimPlugin *plugin) { void *conv_list_handle; + GAIM_DBUS_RETURN_FALSE_IF_DISABLED(plugin); + /* First, we have to register our four exported functions with the main gaim dbus loop. Without this statement, the gaim dbus code wouldn't know about our functions. */ Modified: trunk/src/dbus-server.h =================================================================== --- trunk/src/dbus-server.h 2006-07-17 05:50:49 UTC (rev 16504) +++ trunk/src/dbus-server.h 2006-07-17 06:21:53 UTC (rev 16505) @@ -74,6 +74,17 @@ #define GAIM_DBUS_DEFINE_INHERITING_TYPE(type, parent) \ GaimDBusType GAIM_DBUS_TYPE_##type = { GAIM_DBUS_TYPE(parent) }; +#define GAIM_DBUS_RETURN_FALSE_IF_DISABLED(plugin) \ + if (gaim_dbus_get_init_error() != NULL) \ + { \ + gchar *title; \ + title = g_strdup_printf("Unable to Load %s Plugin", plugin->info->name); \ + gaim_notify_error(NULL, title, \ + _("Gaim's D-BUS server is not running for the reason listed below"), \ + _(gaim_dbus_get_init_error())); \ + g_free(title); \ + return FALSE; \ + } /** Initializes gaim dbus pointer registration engine. @@ -139,8 +150,9 @@ * NOT running then gaim_dbus_dispatch_init() failed for some reason, * and a message should have been gaim_debug_error()'ed. * - * This function should be called by any DBUS plugin before trying - * to use the DBUS API. See plugins/dbus-example.c for usage. + * Gaim plugins that use D-BUS should use the + * GAIM_DBUS_RETURN_FALSE_IF_DISABLED macro to short-circuit + * initialization if Gaim's D-BUS subsystem is not running. * * @return If the D-BUS subsystem started with no problems then this * will return NULL and everything will be hunky dory. If Modified: trunk/src/signals.c =================================================================== --- trunk/src/signals.c 2006-07-17 05:50:49 UTC (rev 16504) +++ trunk/src/signals.c 2006-07-17 06:21:53 UTC (rev 16505) @@ -267,7 +267,13 @@ instance_data = (GaimInstanceData *)g_hash_table_lookup(instance_table, instance); - g_return_val_if_fail(instance_data != NULL, 0); + if (instance_data == NULL) + { + gaim_debug_warning("signals", "Something tried to register a callback " + "for the '%s' signal, but we do not have any signals " + "registered with the given handle\n", signal); + g_return_val_if_reached(0); + } /* Get the signal data */ signal_data = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |