[vinagre/plugin] Make mDNS bookmarks work based on plugins.
- From: Jonh Wendell <jwendell src gnome org>
- To: svn-commits-list gnome org
- Subject: [vinagre/plugin] Make mDNS bookmarks work based on plugins.
- Date: Tue, 21 Jul 2009 13:42:58 +0000 (UTC)
commit 020e0b2ea5283d580bf6d1023961171dcbb8dd7d
Author: Jonh Wendell <jwendell gnome org>
Date: Tue Jul 21 10:40:54 2009 -0300
Make mDNS bookmarks work based on plugins.
When a plugin is loaded, we check if this plugin has mDNS ability.
If so, we load it. When a plugin is unloaded, we deactivate its mDNS
entries.
vinagre/vinagre-mdns.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 47 insertions(+), 2 deletions(-)
---
diff --git a/vinagre/vinagre-mdns.c b/vinagre/vinagre-mdns.c
index 0aaf831..0673bec 100644
--- a/vinagre/vinagre-mdns.c
+++ b/vinagre/vinagre-mdns.c
@@ -187,6 +187,9 @@ vinagre_mdns_add_service (VinagrePluginInfo *info,
BrowserEntry *entry;
VinagrePlugin *plugin;
+ if (!vinagre_plugin_info_is_active (info))
+ return;
+
service = vinagre_plugin_get_mdns_service (info->plugin);
if (!service)
return;
@@ -232,6 +235,27 @@ vinagre_mdns_add_service (VinagrePluginInfo *info,
}
static void
+vinagre_mdns_remove_entries_by_protocol (VinagreMdns *mdns, const gchar *protocol)
+{
+ GSList *l;
+ gboolean changed = FALSE;
+
+ for (l = mdns->priv->entries; l; l = l->next)
+ {
+ VinagreBookmarksEntry *entry = VINAGRE_BOOKMARKS_ENTRY (l->data);
+ if (strcmp (vinagre_connection_get_protocol (vinagre_bookmarks_entry_get_conn (entry)), protocol) == 0)
+ {
+ mdns->priv->entries = g_slist_remove (mdns->priv->entries, entry);
+ g_object_unref (entry);
+ changed = TRUE;
+ }
+ }
+
+ if (changed)
+ g_signal_emit (mdns, signals[MDNS_CHANGED], 0);
+}
+
+static void
plugin_activated_cb (VinagrePluginsEngine *engine,
VinagrePluginInfo *info,
VinagreMdns *mdns)
@@ -240,6 +264,23 @@ plugin_activated_cb (VinagrePluginsEngine *engine,
}
static void
+plugin_deactivated_cb (VinagrePluginsEngine *engine,
+ VinagrePluginInfo *info,
+ VinagreMdns *mdns)
+{
+ const gchar *service;
+
+ service = vinagre_plugin_get_mdns_service (info->plugin);
+ if (!service)
+ return;
+
+ vinagre_mdns_remove_entries_by_protocol (mdns,
+ vinagre_plugin_get_protocol (info->plugin));
+ g_hash_table_remove (mdns->priv->browsers, (gconstpointer)service);
+
+}
+
+static void
vinagre_mdns_init (VinagreMdns *mdns)
{
GError *error = NULL;
@@ -267,9 +308,13 @@ vinagre_mdns_init (VinagreMdns *mdns)
(GFunc)vinagre_mdns_add_service,
mdns);
+ g_signal_connect_after (engine,
+ "activate-plugin",
+ G_CALLBACK (plugin_activated_cb),
+ mdns);
g_signal_connect (engine,
- "activate-plugin",
- G_CALLBACK (plugin_activated_cb),
+ "deactivate-plugin",
+ G_CALLBACK (plugin_deactivated_cb),
mdns);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]