From 1f2f3fd1b6c5c47dc4dfd4c41629358b54cd847f Mon Sep 17 00:00:00 2001 From: Jens Georg Date: Mon, 17 Oct 2011 21:27:13 +0200 Subject: [PATCH] media-export: Deactivate on slow Tracker start-up If the startup of the Tracker plug-in is delayed (e.g. due to DBus activation) the old method of disabling MediaExport did not work since the Tracker plug-in was not active when MediaExport was loaded. The plug-in now listens to notify::active of the Tracker plug-in and deactivates itself once that changes to "true". https://bugzilla.gnome.org/show_bug.cgi?id=662031 --- .../media-export/rygel-media-export-plugin.vala | 56 ++++++++++++++-------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/src/plugins/media-export/rygel-media-export-plugin.vala b/src/plugins/media-export/rygel-media-export-plugin.vala index 3b88997..682209d 100644 --- a/src/plugins/media-export/rygel-media-export-plugin.vala +++ b/src/plugins/media-export/rygel-media-export-plugin.vala @@ -63,32 +63,46 @@ public void module_init (PluginLoader loader) { } public void on_plugin_available (Plugin plugin, Plugin our_plugin) { - if (plugin.name == TRACKER_PLUGIN && - our_plugin.active == plugin.active) { - if (plugin.active) { - message ("Deactivating plugin '%s' in favor of plugin '%s'", - MediaExport.Plugin.NAME, - TRACKER_PLUGIN); - try { - var config = MetaConfig.get_default (); - var enabled = config.get_bool ("MediaExport", "enabled"); - if (enabled) { - var root = Rygel.MediaExport.RootContainer.get_instance () - as Rygel.MediaExport.RootContainer; - - root.shutdown (); + warning ("%s %s %s", plugin.name, our_plugin.active.to_string (), + plugin.active.to_string ()); + if (plugin.name == TRACKER_PLUGIN) { + if (our_plugin.active && !plugin.active) { + // Tracker plugin might be activated later + plugin.notify["active"].connect (() => { + if (plugin.active) { + shutdown_media_export (); + our_plugin.active = !plugin.active; } - } catch (Error error) {}; - } else { - message ("Plugin '%s' inactivate, activating '%s' plugin", - TRACKER_PLUGIN, - MediaExport.Plugin.NAME); + }); + } else if (our_plugin.active == plugin.active) { + if (plugin.active) { + shutdown_media_export (); + } else { + message ("Plugin '%s' inactivate, activating '%s' plugin", + TRACKER_PLUGIN, + MediaExport.Plugin.NAME); + } + our_plugin.active = !plugin.active; } - - our_plugin.active = !plugin.active; } } +private void shutdown_media_export () { + message ("Deactivating plugin '%s' in favor of plugin '%s'", + MediaExport.Plugin.NAME, + TRACKER_PLUGIN); + try { + var config = MetaConfig.get_default (); + var enabled = config.get_bool ("MediaExport", "enabled"); + if (enabled) { + var root = Rygel.MediaExport.RootContainer.get_instance () + as Rygel.MediaExport.RootContainer; + + root.shutdown (); + } + } catch (Error error) {}; +} + public class Rygel.MediaExport.Plugin : Rygel.MediaServerPlugin { public const string NAME = "MediaExport"; -- 2.7.4