[vinagre/libpeas: 10/10] Initial port to libpeas



commit ed9e5bc766f826c0f67eb555248a500de4f51f90
Author: Jonh Wendell <jwendell gnome org>
Date:   Wed Jul 28 12:25:46 2010 +0200

    Initial port to libpeas

 plugins/rdp/rdp.vinagre-plugin.desktop.in |    2 -
 plugins/rdp/vinagre-rdp-plugin.c          |   93 ++++-----
 plugins/rdp/vinagre-rdp-plugin.h          |   29 +--
 vinagre/Makefile.am                       |   16 +-
 vinagre/vinagre-applet.c                  |   10 +-
 vinagre/vinagre-bookmarks-migration.c     |   12 +-
 vinagre/vinagre-bookmarks-ui.c            |   30 ++--
 vinagre/vinagre-bookmarks.c               |   12 +-
 vinagre/vinagre-commands.c                |    4 +-
 vinagre/vinagre-connect.c                 |   43 ++--
 vinagre/vinagre-connection.c              |   51 ++--
 vinagre/vinagre-fav.c                     |   10 +-
 vinagre/vinagre-main.c                    |   11 +-
 vinagre/vinagre-mdns.c                    |   23 +-
 vinagre/vinagre-plugin-dialog.c           |    5 +-
 vinagre/vinagre-plugins-engine.c          |  315 ++++++++++++++++++++++++++
 vinagre/vinagre-plugins-engine.h          |   62 +++++
 vinagre/vinagre-protocol-ext.c            |  191 ++++++++++++++++
 vinagre/vinagre-protocol-ext.h            |   60 +++++
 vinagre/vinagre-protocol.c                |  352 +++++++++++++++++++++++++++++
 vinagre/vinagre-protocol.h                |  104 +++++++++
 vinagre/vinagre-tab.c                     |   40 ++--
 vinagre/vinagre-utils.c                   |    4 +-
 vinagre/vinagre-utils.h                   |    3 +-
 vinagre/vinagre-window.c                  |   17 +-
 25 files changed, 1280 insertions(+), 219 deletions(-)
---
diff --git a/plugins/rdp/rdp.vinagre-plugin.desktop.in b/plugins/rdp/rdp.vinagre-plugin.desktop.in
index cbbc83b..6c2b973 100644
--- a/plugins/rdp/rdp.vinagre-plugin.desktop.in
+++ b/plugins/rdp/rdp.vinagre-plugin.desktop.in
@@ -7,5 +7,3 @@ Authors=Jonh Wendell
 Copyright=Copyright © 2010 Jonh Wendell
 Website=http://www.bani.com.br
 Version=1.0
-Engine=1
-Icon=vinagre
diff --git a/plugins/rdp/vinagre-rdp-plugin.c b/plugins/rdp/vinagre-rdp-plugin.c
index c37690c..eca4ff6 100644
--- a/plugins/rdp/vinagre-rdp-plugin.c
+++ b/plugins/rdp/vinagre-rdp-plugin.c
@@ -25,46 +25,30 @@
 #include <glib/gi18n-lib.h>
 #include <gmodule.h>
 
-#include <vinagre/vinagre-debug.h>
 #include <vinagre/vinagre-cache-prefs.h>
+#include <vinagre/vinagre-protocol.h>
 
 #include "vinagre-rdp-plugin.h"
 #include "vinagre-rdp-connection.h"
 #include "vinagre-rdp-tab.h"
 
-#define VINAGRE_RDP_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), VINAGRE_TYPE_RDP_PLUGIN, VinagreRdpPluginPrivate))
+static void vinagre_protocol_iface_init (VinagreProtocolInterface *iface);
 
-VINAGRE_PLUGIN_REGISTER_TYPE(VinagreRdpPlugin, vinagre_rdp_plugin)
-
-static void
-impl_activate (VinagrePlugin *plugin,
-               VinagreWindow *window)
-{
-  vinagre_debug_message (DEBUG_PLUGINS, "VinagreRdpPlugin Activate");
-}
-
-static void
-impl_deactivate  (VinagrePlugin *plugin,
-                  VinagreWindow *window)
-{
-  vinagre_debug_message (DEBUG_PLUGINS, "VinagreRdpPlugin Deactivate");
-}
-
-static void
-impl_update_ui (VinagrePlugin *plugin,
-                VinagreWindow *window)
-{
-  vinagre_debug_message (DEBUG_PLUGINS, "VinagreRdpPlugin Update UI");
-}
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (VinagreRdpPlugin,
+				vinagre_rdp_plugin,
+				PEAS_TYPE_EXTENSION_BASE,
+				0,
+				G_IMPLEMENT_INTERFACE_DYNAMIC (VINAGRE_TYPE_PROTOCOL,
+							       vinagre_protocol_iface_init))
 
 static const gchar *
-impl_get_protocol (VinagrePlugin *plugin)
+impl_get_protocol (VinagreProtocol *plugin)
 {
   return "rdp";
 }
 
 static gchar **
-impl_get_public_description (VinagrePlugin *plugin)
+impl_get_public_description (VinagreProtocol *plugin)
 {
   gchar **result = g_new (gchar *, 3);
 
@@ -77,13 +61,13 @@ impl_get_public_description (VinagrePlugin *plugin)
 }
 
 static VinagreConnection *
-impl_new_connection (VinagrePlugin *plugin)
+impl_new_connection (VinagreProtocol *plugin)
 {
   return vinagre_rdp_connection_new ();
 }
 
 static GtkWidget *
-impl_new_tab (VinagrePlugin     *plugin,
+impl_new_tab (VinagreProtocol   *plugin,
 	      VinagreConnection *conn,
 	      VinagreWindow     *window)
 {
@@ -91,7 +75,7 @@ impl_new_tab (VinagrePlugin     *plugin,
 }
 
 static gint
-impl_get_default_port (VinagrePlugin *plugin)
+impl_get_default_port (VinagreProtocol *plugin)
 {
   return 3389;
 }
@@ -99,19 +83,10 @@ impl_get_default_port (VinagrePlugin *plugin)
 static void
 vinagre_rdp_plugin_init (VinagreRdpPlugin *plugin)
 {
-  vinagre_debug_message (DEBUG_PLUGINS, "VinagreRdpPlugin initializing");
-}
-
-static void
-vinagre_rdp_plugin_finalize (GObject *object)
-{
-  vinagre_debug_message (DEBUG_PLUGINS, "VinagreRdpPlugin finalizing");
-
-  G_OBJECT_CLASS (vinagre_rdp_plugin_parent_class)->finalize (object);
 }
 
 static GtkWidget *
-impl_get_connect_widget (VinagrePlugin *plugin, VinagreConnection *conn)
+impl_get_connect_widget (VinagreProtocol *plugin, VinagreConnection *conn)
 {
   GtkWidget *box, *label, *u_box, *u_entry;
   gchar     *str;
@@ -151,21 +126,33 @@ impl_get_connect_widget (VinagrePlugin *plugin, VinagreConnection *conn)
 }
 
 static void
+vinagre_protocol_iface_init (VinagreProtocolInterface *iface)
+{
+  iface->get_protocol  = impl_get_protocol;
+  iface->get_public_description  = impl_get_public_description;
+  iface->new_connection = impl_new_connection;
+  iface->new_tab = impl_new_tab;
+  iface->get_default_port = impl_get_default_port;
+  iface->get_connect_widget = impl_get_connect_widget;
+}
+
+static void
+vinagre_rdp_plugin_class_finalize (VinagreRdpPluginClass *klass)
+{
+}
+
+static void
 vinagre_rdp_plugin_class_init (VinagreRdpPluginClass *klass)
 {
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
-  VinagrePluginClass *plugin_class = VINAGRE_PLUGIN_CLASS (klass);
-
-  object_class->finalize   = vinagre_rdp_plugin_finalize;
-
-  plugin_class->activate   = impl_activate;
-  plugin_class->deactivate = impl_deactivate;
-  plugin_class->update_ui  = impl_update_ui;
-  plugin_class->get_protocol  = impl_get_protocol;
-  plugin_class->get_public_description  = impl_get_public_description;
-  plugin_class->new_connection = impl_new_connection;
-  plugin_class->new_tab = impl_new_tab;
-  plugin_class->get_default_port = impl_get_default_port;
-  plugin_class->get_connect_widget = impl_get_connect_widget;
 }
+
+G_MODULE_EXPORT void
+peas_register_types (PeasObjectModule *module)
+{
+  vinagre_rdp_plugin_register_type (G_TYPE_MODULE (module));
+  peas_object_module_register_extension_type (module,
+					      VINAGRE_TYPE_PROTOCOL,
+					      VINAGRE_TYPE_RDP_PLUGIN);
+}
+
 /* vim: set ts=8: */
diff --git a/plugins/rdp/vinagre-rdp-plugin.h b/plugins/rdp/vinagre-rdp-plugin.h
index 213198d..0e53590 100644
--- a/plugins/rdp/vinagre-rdp-plugin.h
+++ b/plugins/rdp/vinagre-rdp-plugin.h
@@ -23,7 +23,7 @@
 
 #include <glib.h>
 #include <glib-object.h>
-#include <vinagre/vinagre-plugin.h>
+#include <libpeas/peas.h>
 
 G_BEGIN_DECLS
 
@@ -37,38 +37,25 @@ G_BEGIN_DECLS
 #define VINAGRE_IS_RDP_PLUGIN_CLASS(k)          (G_TYPE_CHECK_CLASS_TYPE ((k), VINAGRE_TYPE_RDP_PLUGIN))
 #define VINAGRE_RDP_PLUGIN_GET_CLASS(o)         (G_TYPE_INSTANCE_GET_CLASS ((o), VINAGRE_TYPE_RDP_PLUGIN, VinagreRdpPluginClass))
 
-/* Private structure type */
-typedef struct _VinagreRdpPluginPrivate	VinagreRdpPluginPrivate;
-
-/*
- * Main object structure
- */
-typedef struct _VinagreRdpPlugin		VinagreRdpPlugin;
+typedef struct _VinagreRdpPlugin	VinagreRdpPlugin;
+typedef struct _VinagreRdpPluginClass	VinagreRdpPluginClass;
 
 struct _VinagreRdpPlugin
 {
-  VinagrePlugin parent_instance;
+  PeasExtensionBase parent_instance;
 };
 
-/*
- * Class definition
- */
-typedef struct _VinagreRdpPluginClass	VinagreRdpPluginClass;
-
 struct _VinagreRdpPluginClass
 {
-  VinagrePluginClass parent_class;
+  PeasExtensionBaseClass parent_class;
 };
 
-/*
- * Public methods
- */
-GType	vinagre_rdp_plugin_get_type		(void) G_GNUC_CONST;
+GType vinagre_rdp_plugin_get_type (void) G_GNUC_CONST;
 
-/* All the plugins must implement this function */
-G_MODULE_EXPORT GType register_vinagre_plugin (GTypeModule *module);
+G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
 
 G_END_DECLS
 
 #endif /* __VINAGRE_RDP_PLUGIN_H__ */
+
 /* vim: set ts=8: */
diff --git a/vinagre/Makefile.am b/vinagre/Makefile.am
index 21dc48c..722fd78 100644
--- a/vinagre/Makefile.am
+++ b/vinagre/Makefile.am
@@ -19,7 +19,6 @@ INCLUDES = 						\
 NOINST_H_FILES = \
   vinagre-enums.h \
   vinagre-marshal.h \
-  vinagre-object-module.h \
   vinagre-plugin-dialog.h \
   vinagre-window-private.h \
   pty_open.h \
@@ -46,6 +45,9 @@ INST_H_FILES = \
   vinagre-dnd.h \
   vinagre-ssh.h \
   vinagre-cache-prefs.h \
+  vinagre-protocol.h \
+  vinagre-plugins-engine.h \
+  vinagre-protocol-ext.h \
   $(NULL)
 
 headerdir = $(prefix)/include/vinagre- VINAGRE_API_VERSION@/vinagre
@@ -70,7 +72,6 @@ handwritten_sources = \
   vinagre-dirs.c \
   vinagre-fav.c \
   vinagre-notebook.c \
-  vinagre-object-module.c \
   vinagre-plugin-dialog.c \
   vinagre-prefs.c \
   vinagre-tab.c \
@@ -79,6 +80,9 @@ handwritten_sources = \
   pty_open.c \
   vinagre-ssh.c \
   vinagre-cache-prefs.c \
+  vinagre-protocol.c \
+  vinagre-plugins-engine.c \
+  vinagre-protocol-ext.c \
   $(NULL)
 
 libvinagre_la_SOURCES = \
@@ -166,7 +170,6 @@ vinagre_applet_SOURCES =					\
 	vinagre-notebook.h vinagre-notebook.c \
 	vinagre-tab.h vinagre-tab.c \
 	vinagre-prefs.h vinagre-prefs.c \
-	vinagre-object-module.h vinagre-object-module.c \
 	vinagre-dirs.h vinagre-dirs.c \
 	vinagre-fav.h vinagre-fav.c \
 	vinagre-connect.h vinagre-connect.c \
@@ -174,6 +177,9 @@ vinagre_applet_SOURCES =					\
 	pty_open.h pty_open.c \
 	vinagre-ssh.h vinagre-ssh.c \
 	vinagre-cache-prefs.h vinagre-cache-prefs.c \
+	vinagre-protocol.h vinagre-protocol.c \
+	vinagre-plugins-engine.h vinagre-plugins-engine.c \
+	vinagre-protocol-ext.h vinagre-protocol-ext.c \
 	$(NULL)
 
 if AVAHI
@@ -275,12 +281,12 @@ Vinagre_3_0_gir_NAMESPACE = Vinagre
 Vinagre_3_0_gir_VERSION = 3.0
 Vinagre_3_0_gir_PROGRAM = $(builddir)/vinagre
 Vinagre_3_0_gir_FILES = $(INST_H_FILES) $(NOINST_H_FILES) $(handwritten_sources)
-Vinagre_3_0_gir_INCLUDES = Gtk-3.0 libxml2-2.0
+Vinagre_3_0_gir_INCLUDES = Gtk-3.0 libxml2-2.0 Peas-1.0 PeasUI-1.0
 
 girdir = $(datadir)/vinagre/gir-1.0
 gir_DATA = $(INTROSPECTION_GIRS)
 
-typelibdir = $(libdir)/vinagre/girepository-1.0
+typelibdir = $(libdir)/girepository-1.0
 typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
 endif
 
diff --git a/vinagre/vinagre-applet.c b/vinagre/vinagre-applet.c
index 83e13d5..b51fabb 100644
--- a/vinagre/vinagre-applet.c
+++ b/vinagre/vinagre-applet.c
@@ -30,7 +30,7 @@
 #include "vinagre-utils.h"
 #include "vinagre-connection.h"
 #include "vinagre-commands.h"
-#include "vinagre-plugin.h"
+#include "vinagre-protocol-ext.h"
 #include "vinagre-plugins-engine.h"
 
 #include <config.h>
@@ -298,7 +298,7 @@ fill_recursive_menu (GSList *entries, GtkWidget *menu)
     {
       VinagreBookmarksEntry *entry = VINAGRE_BOOKMARKS_ENTRY (l->data);
       VinagreConnection     *conn;
-      VinagrePlugin         *plugin;
+      VinagreProtocolExt    *ext;
 
       switch (vinagre_bookmarks_entry_get_node (entry))
 	{
@@ -319,10 +319,10 @@ fill_recursive_menu (GSList *entries, GtkWidget *menu)
 
 	  case VINAGRE_BOOKMARKS_ENTRY_NODE_CONN:
 	    conn = vinagre_bookmarks_entry_get_conn (entry);
-	    plugin = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (),
-								    vinagre_connection_get_protocol (conn));
+	    ext = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (),
+								 vinagre_connection_get_protocol (conn));
 
-	    image = gtk_image_new_from_icon_name (vinagre_plugin_get_icon_name (plugin),
+	    image = gtk_image_new_from_icon_name (vinagre_protocol_ext_get_icon_name (ext),
 						  GTK_ICON_SIZE_MENU);
 	    item = gtk_image_menu_item_new_with_label (vinagre_connection_get_name (conn));
 	    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
diff --git a/vinagre/vinagre-bookmarks-migration.c b/vinagre/vinagre-bookmarks-migration.c
index a8139f1..f6debaa 100644
--- a/vinagre/vinagre-bookmarks-migration.c
+++ b/vinagre/vinagre-bookmarks-migration.c
@@ -34,7 +34,7 @@
 #include "vinagre-connection.h"
 #include "vinagre-bookmarks-migration.h"
 #include "vinagre-bookmarks.h"
-#include "vinagre-plugin.h"
+#include "vinagre-protocol-ext.h"
 #include "vinagre-plugins-engine.h"
 #include "vinagre-dirs.h"
 #include "vinagre-utils.h"
@@ -156,11 +156,11 @@ create_list (GKeyFile *kf)
   GSList *entries;
   gchar **conns;
   gsize   length, i;
-  VinagrePlugin *plugin;
+  VinagreProtocolExt *ext;
 
-  plugin = g_hash_table_lookup (vinagre_plugin_engine_get_plugins_by_protocol (vinagre_plugins_engine_get_default ()),
-				"vnc");
-  if (!plugin)
+  ext = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (), "vnc");
+
+  if (!ext)
     {
       g_warning (_("Error while migrating bookmarks: VNC plugin is not activated"));
       return NULL;
@@ -178,7 +178,7 @@ create_list (GKeyFile *kf)
       if (!s_value)
         continue;
 
-      conn = vinagre_plugin_new_connection (plugin);
+      conn = vinagre_protocol_ext_new_connection (ext);
       i_value = g_key_file_get_integer (kf, conns[i], "port", NULL);
       if (i_value == 0)
         i_value = 5900;
diff --git a/vinagre/vinagre-bookmarks-ui.c b/vinagre/vinagre-bookmarks-ui.c
index 17fd6bd..af1cca2 100644
--- a/vinagre/vinagre-bookmarks-ui.c
+++ b/vinagre/vinagre-bookmarks-ui.c
@@ -24,7 +24,7 @@
 #include "vinagre-bookmarks-ui.h"
 #include "vinagre-utils.h"
 #include "vinagre-bookmarks-tree.h"
-#include "vinagre-plugin.h"
+#include "vinagre-protocol-ext.h"
 #include "vinagre-plugins-engine.h"
 
 static void
@@ -118,16 +118,16 @@ show_dialog_conn (VinagreBookmarks      *book,
 		  VinagreBookmarksEntry *entry,
 		  gboolean               is_add)
 {
-  gchar             *str, *host, *error_str, *protocol;
-  gint               port;
-  GtkBuilder        *xml;
-  GtkWidget         *dialog, *host_entry, *name_entry, *fs_check;
-  GtkWidget         *folder_box, *tree, *save_button, *plugin_box;
-  GtkWidget         *plugin_options, *protocol_label;
-  VinagreConnection *conn;
-  const gchar       *name;
-  VinagrePlugin     *plugin;
-  gchar             **props;
+  gchar              *str, *host, *error_str, *protocol;
+  gint                port;
+  GtkBuilder         *xml;
+  GtkWidget          *dialog, *host_entry, *name_entry, *fs_check;
+  GtkWidget          *folder_box, *tree, *save_button, *plugin_box;
+  GtkWidget          *plugin_options, *protocol_label;
+  VinagreConnection  *conn;
+  const gchar        *name;
+  VinagreProtocolExt *ext;
+  gchar              **props;
 
   xml = vinagre_utils_get_builder (NULL, NULL);
   dialog         = GTK_WIDGET (gtk_builder_get_object (xml, "bookmarks_add_edit_conn_dialog"));
@@ -155,15 +155,15 @@ show_dialog_conn (VinagreBookmarks      *book,
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fs_check),
 				vinagre_connection_get_fullscreen (conn));
 
-  plugin = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (),
-							  vinagre_connection_get_protocol (conn));
-  plugin_options = vinagre_plugin_get_connect_widget (plugin, conn);
+  ext = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (),
+						       vinagre_connection_get_protocol (conn));
+  plugin_options = vinagre_protocol_ext_get_connect_widget (ext, conn);
   if (plugin_options)
     gtk_box_pack_start (GTK_BOX (plugin_box), plugin_options, TRUE, TRUE, 0);
   else
     gtk_widget_hide (plugin_box);
 
-  props = vinagre_plugin_get_public_description (plugin);
+  props = vinagre_protocol_ext_get_public_description (ext);
   /* Translators: %s is a protocol name, like VNC or SSH */
   str = g_strdup_printf (_("(Protocol: %s)"), props[0]);
   gtk_label_set_label (GTK_LABEL (protocol_label), str);
diff --git a/vinagre/vinagre-bookmarks.c b/vinagre/vinagre-bookmarks.c
index 6bb04ba..8ce69a9 100644
--- a/vinagre/vinagre-bookmarks.c
+++ b/vinagre/vinagre-bookmarks.c
@@ -28,9 +28,9 @@
 #include "vinagre-bookmarks-entry.h"
 #include "vinagre-bookmarks-migration.h"
 #include "vinagre-connection.h"
-#include "vinagre-plugin.h"
 #include "vinagre-plugins-engine.h"
 #include "vinagre-dirs.h"
+#include "vinagre-protocol-ext.h"
 
 struct _VinagreBookmarksPrivate
 {
@@ -242,7 +242,7 @@ vinagre_bookmarks_parse_item (xmlNode *root)
   xmlNode               *curr;
   xmlChar               *s_value;
   gchar                 *protocol = NULL;
-  VinagrePlugin         *plugin;
+  VinagreProtocolExt    *ext;
 
   /* Loop to discover the protocol */
   for (curr = root->children; curr; curr = curr->next)
@@ -259,15 +259,15 @@ vinagre_bookmarks_parse_item (xmlNode *root)
   if (!protocol)
     protocol = g_strdup ("vnc");
 
-  plugin = g_hash_table_lookup (vinagre_plugin_engine_get_plugins_by_protocol (vinagre_plugins_engine_get_default ()),
-				protocol);
-  if (!plugin)
+  ext = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (), protocol);
+
+  if (!ext)
     {
       g_warning (_("The protocol %s is not supported."), protocol);
       goto out;
     }
 
-  conn = vinagre_plugin_new_connection (plugin);
+  conn = vinagre_protocol_ext_new_connection (ext);
   vinagre_connection_parse_item (conn, root);
 
   if (vinagre_connection_get_host (conn))
diff --git a/vinagre/vinagre-commands.c b/vinagre/vinagre-commands.c
index 993b9ce..4597f43 100644
--- a/vinagre/vinagre-commands.c
+++ b/vinagre/vinagre-commands.c
@@ -39,7 +39,7 @@
 #include "vinagre-window-private.h"
 #include "vinagre-prefs.h"
 #include "vinagre-cache-prefs.h"
-#include "vinagre-plugin.h"
+#include "vinagre-protocol-ext.h"
 #include "vinagre-plugins-engine.h"
 #include "vinagre-plugin-dialog.h"
 
@@ -127,6 +127,7 @@ vinagre_cmd_machine_open (GtkAction     *action,
   gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), FALSE);
   gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
 
+/* TODO
   plugins = (GSList *) vinagre_plugins_engine_get_plugin_list (vinagre_plugins_engine_get_default ());
   i = 0;
   for (; plugins; plugins = plugins->next)
@@ -143,6 +144,7 @@ vinagre_cmd_machine_open (GtkAction     *action,
 	  i++;
 	}
     }
+*/
   if (i == 0)
     {
       vinagre_utils_show_error (_("There are no supported files"),
diff --git a/vinagre/vinagre-connect.c b/vinagre/vinagre-connect.c
index 3ec88b0..2a253ab 100644
--- a/vinagre/vinagre-connect.c
+++ b/vinagre/vinagre-connect.c
@@ -37,7 +37,7 @@
 #include "vinagre-prefs.h"
 #include "vinagre-cache-prefs.h"
 #include "vinagre-plugins-engine.h"
-#include "vinagre-plugin.h"
+#include "vinagre-protocol-ext.h"
 #include "vinagre-dirs.h"
 
 typedef struct {
@@ -129,7 +129,7 @@ protocol_combo_changed (GtkComboBox *combo, VinagreConnectDialog *dialog)
 static void
 setup_protocol (VinagreConnectDialog *dialog)
 {
-  GHashTable      *plugins;
+  GHashTable      *extensions;
   GHashTableIter  hash_iter;
   gpointer        key, value;
   GtkTreeIter     tree_iter;
@@ -138,31 +138,32 @@ setup_protocol (VinagreConnectDialog *dialog)
   gint            selected, i;
 
   dialog->protocol_store = gtk_list_store_new (N_PROTOCOLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_OBJECT, G_TYPE_OBJECT);
-  plugins = vinagre_plugin_engine_get_plugins_by_protocol (vinagre_plugins_engine_get_default ());
+  extensions = vinagre_plugins_engine_get_plugins_by_protocol (vinagre_plugins_engine_get_default ());
   last_protocol = vinagre_cache_prefs_get_string ("connection", "last-protocol", NULL);
 
-  g_hash_table_iter_init (&hash_iter, plugins);
+  g_hash_table_iter_init (&hash_iter, extensions);
   selected = 0;
   i = 0;
   while (g_hash_table_iter_next (&hash_iter, &key, &value)) 
     {
-      gchar         **description;
-      VinagrePlugin *plugin = VINAGRE_PLUGIN (value);
-      GtkWidget     *widget;
+      gchar **description;
+      GtkWidget *widget;
+      VinagreProtocolExt *ext =  (VinagreProtocolExt *)value;
 
-      description = vinagre_plugin_get_public_description (plugin);
+      description = vinagre_protocol_ext_get_public_description (ext);
       if (!description || !description[0])
 	continue;
 
-      widget = vinagre_plugin_get_connect_widget (plugin, NULL);
+      //widget = vinagre_protocol_ext_get_connect_widget (ext, NULL);
+      widget = NULL;
 
       gtk_list_store_append (dialog->protocol_store, &tree_iter);
       gtk_list_store_set (dialog->protocol_store, &tree_iter,
 			  PROTOCOL_NAME, description[0],
 			  PROTOCOL_DESCRIPTION, description[1],
-			  PROTOCOL_MDNS, vinagre_plugin_get_mdns_service (plugin),
+			  PROTOCOL_MDNS, vinagre_protocol_ext_get_mdns_service (ext),
 			  PROTOCOL_OPTIONS, widget,
-			  PROTOCOL_PLUGIN, plugin,
+			  PROTOCOL_PLUGIN, ext,
 			  -1);
 
       if (last_protocol && g_str_equal (last_protocol, description[0]))
@@ -330,7 +331,7 @@ vinagre_connect_find_button_cb (GtkButton            *button,
   GtkTreeIter   tree_iter;
   gchar         *service;
   GtkWidget     *options = NULL;
-  VinagrePlugin *plugin = NULL;
+  VinagreProtocol *plugin = NULL;
 
   if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->protocol_combo),
 				      &tree_iter))
@@ -380,7 +381,7 @@ vinagre_connect_find_button_cb (GtkButton            *button,
 
       g_free (tmp);
       if (plugin && options)
-	vinagre_plugin_parse_mdns_dialog (plugin, options, d);
+	vinagre_protocol_parse_mdns_dialog (plugin, options, d);
     }
 
   g_free (service);
@@ -431,11 +432,11 @@ VinagreConnection *vinagre_connect (VinagreWindow *window)
 
   if (result == GTK_RESPONSE_OK)
     {
-      gchar         *host = NULL, *error_msg = NULL, *protocol = NULL, *actual_host;
-      gint          port;
-      VinagrePlugin *plugin;
-      GtkWidget     *options;
-      GtkTreeIter   iter;
+      gchar *host = NULL, *error_msg = NULL, *protocol = NULL, *actual_host;
+      gint port;
+      GtkWidget *options;
+      GtkTreeIter iter;
+      VinagreProtocolExt *ext;
 
       host = gtk_combo_box_get_active_text (GTK_COMBO_BOX (dialog.host_entry));
       gtk_widget_hide (GTK_WIDGET (dialog.dialog));
@@ -454,14 +455,14 @@ VinagreConnection *vinagre_connect (VinagreWindow *window)
       gtk_tree_model_get (GTK_TREE_MODEL (dialog.protocol_store), &iter,
 			  PROTOCOL_NAME, &protocol,
 			  PROTOCOL_OPTIONS, &options,
-			  PROTOCOL_PLUGIN, &plugin,
+			  PROTOCOL_PLUGIN, &ext,
 		      -1);
 
       vinagre_cache_prefs_set_string ("connection", "last-protocol", protocol);
       g_free (protocol);
       vinagre_cache_prefs_set_boolean ("connection", "fullscreen", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog.fullscreen_check)));
 
-      conn = vinagre_plugin_new_connection (plugin);
+      conn = vinagre_protocol_ext_new_connection (ext);
       if (vinagre_connection_split_string (host,
 					   vinagre_connection_get_protocol (conn),
 					   &protocol,
@@ -487,7 +488,7 @@ VinagreConnection *vinagre_connect (VinagreWindow *window)
 				    GTK_WINDOW (window));
 	}
 
-      g_object_unref (plugin);
+      g_object_unref (ext);
       if (options)
 	g_object_unref (options);
 
diff --git a/vinagre/vinagre-connection.c b/vinagre/vinagre-connection.c
index f4c607a..42b7d84 100644
--- a/vinagre/vinagre-connection.c
+++ b/vinagre/vinagre-connection.c
@@ -26,7 +26,7 @@
 #include "vinagre-connection.h"
 #include "vinagre-enums.h"
 #include "vinagre-bookmarks.h"
-#include "vinagre-plugin.h"
+#include "vinagre-protocol-ext.h"
 #include "vinagre-plugins-engine.h"
 #include "vinagre-utils.h"
 
@@ -495,7 +495,7 @@ vinagre_connection_split_string (const gchar *uri,
   gint    lport;
   gchar  *lhost;
   gchar   ipv6_host[255] = {0,};
-  VinagrePlugin *plugin;
+  VinagreProtocolExt *ext;
 
   *error_msg = NULL;
   *host = NULL;
@@ -519,9 +519,9 @@ vinagre_connection_split_string (const gchar *uri,
       lhost = (gchar *) uri;
     }
 
-  plugin = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (),
-							  *protocol);
-  if (!plugin)
+  ext = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (),
+						       *protocol);
+  if (!ext)
     {
       *error_msg = g_strdup_printf (_("The protocol %s is not supported."), *protocol);
       g_free (*protocol);
@@ -545,12 +545,12 @@ vinagre_connection_split_string (const gchar *uri,
   if (g_strrstr (lhost, "::") != NULL)
     {
       server = g_strsplit (lhost, "::", 2);
-      lport = server[1] ? atoi (server[1]) : vinagre_plugin_get_default_port (plugin);
+      lport = server[1] ? atoi (server[1]) : vinagre_protocol_ext_get_default_port (ext);
     }
   else
     {
       server = g_strsplit (lhost, ":", 2);
-      lport = server[1] ? atoi (server[1]) : vinagre_plugin_get_default_port (plugin);
+      lport = server[1] ? atoi (server[1]) : vinagre_protocol_ext_get_default_port (ext);
 
       if ((g_str_equal (*protocol, "vnc")) && (lport < 1024))
         lport += 5900;
@@ -573,7 +573,7 @@ vinagre_connection_new_from_string (const gchar *uri, gchar **error_msg, gboolea
   VinagreConnection *conn = NULL;
   gint    port;
   gchar  *host, *protocol;
-  VinagrePlugin *plugin;
+  VinagreProtocolExt *ext;
 
   if (!vinagre_connection_split_string (uri, NULL, &protocol, &host, &port, error_msg))
     return NULL;
@@ -585,12 +585,12 @@ vinagre_connection_new_from_string (const gchar *uri, gchar **error_msg, gboolea
 				     port);
   if (!conn)
     {
-      plugin = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (),
-							      protocol);
-      if (!plugin)
+      ext = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (),
+							   protocol);
+      if (!ext)
 	goto finalize;
 
-      conn = vinagre_plugin_new_connection (plugin);
+      conn = vinagre_protocol_ext_new_connection (ext);
       vinagre_connection_set_host (conn, host);
       vinagre_connection_set_port (conn, port);
     }
@@ -608,9 +608,9 @@ vinagre_connection_new_from_file (const gchar *uri, gchar **error_msg, gboolean
   gchar             *data;
   GFile             *file_a;
   GError            *error;
-  GHashTable        *plugins;
+  GHashTable        *extensions;
   GHashTableIter     iter;
-  gpointer           plugin;
+  gpointer           ext;
 
   *error_msg = NULL;
   data = NULL;
@@ -636,14 +636,14 @@ vinagre_connection_new_from_file (const gchar *uri, gchar **error_msg, gboolean
       goto the_end;
     }
 
-  plugins = vinagre_plugin_engine_get_plugins_by_protocol (vinagre_plugins_engine_get_default ());
-  g_hash_table_iter_init (&iter, plugins);
-  while (g_hash_table_iter_next (&iter, NULL, &plugin))
+  extensions = vinagre_plugins_engine_get_plugins_by_protocol (vinagre_plugins_engine_get_default ());
+  g_hash_table_iter_init (&iter, extensions);
+  while (g_hash_table_iter_next (&iter, NULL, &ext))
     {
-      conn = vinagre_plugin_new_connection_from_file (VINAGRE_PLUGIN (plugin),
-						      data,
-						      use_bookmarks,
-						      error_msg);
+      conn = vinagre_protocol_ext_new_connection_from_file ((VinagreProtocolExt *)ext,
+							    data,
+							    use_bookmarks,
+							    error_msg);
       g_free (*error_msg);
       *error_msg = NULL;
       if (conn)
@@ -667,7 +667,7 @@ vinagre_connection_get_string_rep (VinagreConnection *conn,
   GString *uri;
   gchar *result;
   gboolean is_ipv6;
-  VinagrePlugin *plugin;
+  VinagreProtocolExt *ext;
 
   g_return_val_if_fail (VINAGRE_IS_CONNECTION (conn), NULL);
 
@@ -687,10 +687,9 @@ vinagre_connection_get_string_rep (VinagreConnection *conn,
   if (is_ipv6)
     g_string_append_c (uri, ']');
 
-  plugin = g_hash_table_lookup (vinagre_plugin_engine_get_plugins_by_protocol (vinagre_plugins_engine_get_default ()),
-				conn->priv->protocol);
-  if (plugin)
-    if (vinagre_plugin_get_default_port (plugin) != conn->priv->port)
+  ext = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (), conn->priv->protocol);
+  if (ext)
+    if (vinagre_protocol_ext_get_default_port (ext) != conn->priv->port)
       g_string_append_printf (uri, "::%d", conn->priv->port);
 
   result = uri->str;
diff --git a/vinagre/vinagre-fav.c b/vinagre/vinagre-fav.c
index b92da9b..70c7c6f 100644
--- a/vinagre/vinagre-fav.c
+++ b/vinagre/vinagre-fav.c
@@ -30,7 +30,7 @@
 #include "vinagre-bookmarks-ui.h"
 #include "vinagre-window-private.h"
 #include "vinagre-bookmarks-entry.h"
-#include "vinagre-plugin.h"
+#include "vinagre-protocol-ext.h"
 #include "vinagre-plugins-engine.h"
 #include "vinagre-commands.h"
 
@@ -963,7 +963,7 @@ vinagre_fav_fill_bookmarks (GtkTreeStore *store, GSList *list, GtkTreeIter *pare
   GSList                *l;
   GtkTreeIter            iter;
   VinagreConnection     *conn;
-  VinagrePlugin         *plugin;
+  VinagreProtocolExt    *ext;
 
  for (l = list; l; l = l->next)
     {
@@ -996,10 +996,10 @@ vinagre_fav_fill_bookmarks (GtkTreeStore *store, GSList *list, GtkTreeIter *pare
 	  case VINAGRE_BOOKMARKS_ENTRY_NODE_CONN:
 	    conn = vinagre_bookmarks_entry_get_conn (entry);
 	    name = vinagre_connection_get_best_name (conn);
-	    plugin = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (),
-								    vinagre_connection_get_protocol (conn));
+	    ext = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (),
+								 vinagre_connection_get_protocol (conn));
 
-	    pixbuf = vinagre_plugin_get_icon (plugin, 16);
+	    pixbuf = vinagre_protocol_ext_get_icon (ext, 16);
 
 	    gtk_tree_store_append (store, &iter, parent_iter);
 	    gtk_tree_store_set (store, &iter,
diff --git a/vinagre/vinagre-main.c b/vinagre/vinagre-main.c
index 7a895b6..cb012f0 100644
--- a/vinagre/vinagre-main.c
+++ b/vinagre/vinagre-main.c
@@ -34,10 +34,10 @@
 #include "vinagre-utils.h"
 #include "vinagre-prefs.h"
 #include "vinagre-cache-prefs.h"
-#include "vinagre-plugins-engine.h"
 #include "vinagre-debug.h"
 #include "vinagre-ssh.h"
 #include "vinagre-options.h"
+#include "vinagre-protocol-ext.h"
 
 #ifdef HAVE_TELEPATHY
 #include "vinagre-tubes-manager.h"
@@ -53,7 +53,7 @@ int main (int argc, char **argv) {
   GSList               *l, *plugins;
   GtkWindow            *window;
   GtkApplication       *app;
-  VinagrePluginsEngine *engine;
+//  VinagrePluginsEngine *engine;
 #ifdef HAVE_TELEPATHY
   VinagreTubesManager *vinagre_tubes_manager;
 #endif
@@ -73,8 +73,8 @@ int main (int argc, char **argv) {
 
   /* Init plugins engine */
   vinagre_debug_message (DEBUG_APP, "Init plugins");
-  engine = vinagre_plugins_engine_get_default ();
-  plugins = (GSList *) vinagre_plugins_engine_get_plugin_list (engine);
+  //engine = vinagre_plugins_engine_get_default ();
+  //plugins = (GSList *) vinagre_plugins_engine_get_plugin_list (engine);
 
   /* Setup command line options */
   context = g_option_context_new (_("- Remote Desktop Viewer"));
@@ -85,6 +85,7 @@ int main (int argc, char **argv) {
   g_option_context_add_group (context, g_irepository_get_option_group ());
 #endif
 
+/*
   for (l = plugins; l; l = l->next)
     {
       GSList            *groups, *l2;
@@ -98,7 +99,7 @@ int main (int argc, char **argv) {
 	g_option_context_add_group (context, (GOptionGroup *)l2->data);
       g_slist_free (groups);
     }
-
+*/
   g_option_context_parse (context, &argc, &argv, &error);
   g_option_context_free (context);
   if (error)
diff --git a/vinagre/vinagre-mdns.c b/vinagre/vinagre-mdns.c
index 29ebdac..704d254 100644
--- a/vinagre/vinagre-mdns.c
+++ b/vinagre/vinagre-mdns.c
@@ -27,7 +27,9 @@
 #include "vinagre-connection.h"
 #include "vinagre-bookmarks-entry.h"
 #include "vinagre-plugins-engine.h"
-#include "vinagre-plugin.h"
+#include "vinagre-protocol-ext.h"
+
+typedef struct {void *plugin; char*name;} VinagrePluginInfo;
 
 typedef struct
 {
@@ -94,7 +96,7 @@ mdns_resolver_found (GaServiceResolver *resolver,
     }
 
   avahi_address_snprint (a, sizeof(a), address);
-  conn = vinagre_plugin_new_connection (b_entry->info->plugin);
+  conn = vinagre_protocol_new_connection (b_entry->info->plugin);
   g_object_set (conn,
                 "name", name,
                 "port", port,
@@ -189,7 +191,7 @@ static void
 destroy_browser_entry (BrowserEntry *entry)
 {
   g_object_unref (entry->browser);
-  _vinagre_plugin_info_unref (entry->info);
+//  _vinagre_plugin_info_unref (entry->info);
   g_free (entry);
 }
 
@@ -202,10 +204,10 @@ vinagre_mdns_add_service (VinagrePluginInfo *info,
   const gchar      *service;
   BrowserEntry     *entry;
 
-  if (!vinagre_plugin_info_is_active (info))
-    return;
+//  if (!vinagre_plugin_info_is_active (info))
+//    return;
 
-  service = vinagre_plugin_get_mdns_service (info->plugin);
+  service = vinagre_protocol_get_mdns_service (info->plugin);
   if (!service)
     return;
 
@@ -245,7 +247,7 @@ vinagre_mdns_add_service (VinagrePluginInfo *info,
 
   entry = g_new (BrowserEntry, 1);
   entry->browser = g_object_ref (browser);
-  _vinagre_plugin_info_ref (info);
+  //_vinagre_plugin_info_ref (info);
   entry->info = info;
   g_hash_table_insert (mdns->priv->browsers, (gpointer)service, entry);
 }
@@ -286,12 +288,12 @@ plugin_deactivated_cb (VinagrePluginsEngine *engine,
 {
   const gchar *service;
 
-  service = vinagre_plugin_get_mdns_service (info->plugin);
+  service = vinagre_protocol_get_mdns_service (info->plugin);
   if (!service)
     return;
 
   vinagre_mdns_remove_entries_by_protocol (mdns,
-					   vinagre_plugin_get_protocol (info->plugin));
+					   vinagre_protocol_get_protocol (info->plugin));
   g_hash_table_remove (mdns->priv->browsers, (gconstpointer)service);
 
 }
@@ -319,11 +321,12 @@ vinagre_mdns_init (VinagreMdns *mdns)
     }
 
   engine = vinagre_plugins_engine_get_default ();
+/*
   plugins = (GSList *)vinagre_plugins_engine_get_plugin_list (engine);
   g_slist_foreach (plugins,
 		   (GFunc)vinagre_mdns_add_service,
 		   mdns);
-
+*/
   g_signal_connect_after (engine,
 			  "activate-plugin",
 			  G_CALLBACK (plugin_activated_cb),
diff --git a/vinagre/vinagre-plugin-dialog.c b/vinagre/vinagre-plugin-dialog.c
index 17d0348..578d383 100644
--- a/vinagre/vinagre-plugin-dialog.c
+++ b/vinagre/vinagre-plugin-dialog.c
@@ -20,9 +20,10 @@
  */
 
 #include <glib/gi18n.h>
+#include <libpeasui/peas-ui-plugin-manager.h>
 
 #include "vinagre-plugin-dialog.h"
-#include "vinagre-debug.h"
+#include "vinagre-plugins-engine.h"
 
 static GtkWidget *plugin_dialog = NULL;
 
@@ -61,7 +62,7 @@ setup_plugins_page (VinagrePluginDialog *dlg)
 {
   GtkWidget *page_content;
 
-  page_content = vinagre_plugin_manager_new ();
+  page_content = peas_ui_plugin_manager_new (PEAS_ENGINE (vinagre_plugins_engine_get_default ()));
   g_return_if_fail (page_content != NULL);
 
   gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
diff --git a/vinagre/vinagre-plugins-engine.c b/vinagre/vinagre-plugins-engine.c
new file mode 100644
index 0000000..2164c31
--- /dev/null
+++ b/vinagre/vinagre-plugins-engine.c
@@ -0,0 +1,315 @@
+/*
+ * vinagre-plugins-engine.c
+ * This file is part of vinagre
+ *
+ * Copyright (C) 2010 Jonh Wendell <wendell bani com br>
+ *
+ * vinagre-plugins-engine.c is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * vinagre-plugins-engine.c is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <girepository.h>
+
+#include "vinagre-plugins-engine.h"
+#include "vinagre-dirs.h"
+#include "vinagre-debug.h"
+#include "vinagre-protocol.h"
+
+#define VINAGRE_PLUGINS_ENGINE_BASE_KEY "/apps/vinagre-2/plugins"
+#define VINAGRE_PLUGINS_ENGINE_KEY VINAGRE_PLUGINS_ENGINE_BASE_KEY "/active-plugins"
+
+G_DEFINE_TYPE (VinagrePluginsEngine, vinagre_plugins_engine, PEAS_TYPE_ENGINE)
+
+struct _VinagrePluginsEnginePrivate
+{
+  //GSettings *plugin_settings;
+  gboolean loading_plugin_list : 1;
+  GHashTable *protocols;
+  PeasExtensionSet *extensions;
+};
+
+VinagrePluginsEngine *default_engine = NULL;
+
+static void
+vinagre_plugins_engine_extension_added (PeasExtensionSet     *extensions,
+					PeasPluginInfo       *info,
+					PeasExtension        *exten,
+					VinagrePluginsEngine *engine)
+{
+  PeasExtension *previous_ext;
+  const gchar *protocol = NULL;
+
+  peas_extension_call (exten, "get_protocol", &protocol);
+
+  previous_ext = g_hash_table_lookup (engine->priv->protocols, protocol);
+
+  if (previous_ext)
+    {
+      g_warning ("The protocol %s was already registered by the plugin %s",
+		 protocol,
+		 peas_plugin_info_get_name (info));
+      return;
+    }
+
+  g_hash_table_insert (engine->priv->protocols, (gpointer)protocol, exten);
+}
+
+static void
+vinagre_plugins_engine_extension_removed (PeasExtensionSet    *extensions,
+					  PeasPluginInfo      *info,
+					  PeasExtension       *exten,
+					 VinagrePluginsEngine *engine)
+{
+  const gchar *protocol = NULL;
+
+  peas_extension_call (exten, "get_protocol", &protocol);
+
+  g_hash_table_remove (engine->priv->protocols, (gpointer)protocol);
+}
+
+static void
+vinagre_plugins_engine_init (VinagrePluginsEngine *engine)
+{
+  engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine,
+					      VINAGRE_TYPE_PLUGINS_ENGINE,
+					      VinagrePluginsEnginePrivate);
+
+  //engine->priv->plugin_settings = g_settings_new ("org.gnome.vinagre.plugins");
+  engine->priv->loading_plugin_list = FALSE;
+  engine->priv->protocols = g_hash_table_new (g_str_hash, g_str_equal);
+
+  engine->priv->extensions = peas_extension_set_new (PEAS_ENGINE (engine),
+						     VINAGRE_TYPE_PROTOCOL,
+						     NULL);
+  g_signal_connect (engine->priv->extensions,
+		    "extension-added",
+		    G_CALLBACK (vinagre_plugins_engine_extension_added),
+		    engine);
+  g_signal_connect (engine->priv->extensions,
+		    "extension-removed",
+		    G_CALLBACK (vinagre_plugins_engine_extension_removed),
+		    engine);
+}
+
+static void
+vinagre_plugins_engine_finalize (GObject *object)
+{
+  VinagrePluginsEngine *engine = VINAGRE_PLUGINS_ENGINE (object);
+
+  g_hash_table_destroy (engine->priv->protocols);
+
+  G_OBJECT_CLASS (vinagre_plugins_engine_parent_class)->finalize (object);
+}
+
+static void
+save_plugin_list (VinagrePluginsEngine *engine)
+{
+  gchar **loaded_plugins;
+
+  loaded_plugins = peas_engine_get_loaded_plugins (PEAS_ENGINE (engine));
+/*
+  g_settings_set_strv (engine->priv->plugin_settings,
+		       VINAGRE_SETTINGS_ACTIVE_PLUGINS,
+		       (const gchar * const *) loaded_plugins);
+*/
+  g_strfreev (loaded_plugins);
+}
+
+static void
+vinagre_plugins_engine_load_plugin (PeasEngine     *engine,
+				    PeasPluginInfo *info)
+{
+  VinagrePluginsEngine *vengine = VINAGRE_PLUGINS_ENGINE (engine);
+
+  PEAS_ENGINE_CLASS (vinagre_plugins_engine_parent_class)->load_plugin (engine, info);
+
+  /* We won't save the plugin list if we are currently loading the
+   * plugins from the saved list */
+  if (!vengine->priv->loading_plugin_list && peas_plugin_info_is_loaded (info))
+    save_plugin_list (vengine);
+}
+
+static void
+vinagre_plugins_engine_unload_plugin (PeasEngine     *engine,
+				      PeasPluginInfo *info)
+{
+  VinagrePluginsEngine *vengine = VINAGRE_PLUGINS_ENGINE (engine);
+
+  PEAS_ENGINE_CLASS (vinagre_plugins_engine_parent_class)->unload_plugin (engine, info);
+
+  /* We won't save the plugin list if we are currently unloading the
+   * plugins from the saved list */
+  if (!vengine->priv->loading_plugin_list && !peas_plugin_info_is_loaded (info))
+    save_plugin_list (vengine);
+}
+
+static void
+vinagre_plugins_engine_class_init (VinagrePluginsEngineClass *klass)
+{
+  PeasEngineClass *engine_class = PEAS_ENGINE_CLASS (klass);
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = vinagre_plugins_engine_finalize;
+
+  engine_class->load_plugin = vinagre_plugins_engine_load_plugin;
+  engine_class->unload_plugin = vinagre_plugins_engine_unload_plugin;
+
+  g_type_class_add_private (klass, sizeof (VinagrePluginsEnginePrivate));
+}
+
+/*
+static void
+require_private_typelib (void)
+{
+	const gchar *lib_dir;
+	gchar *filename;
+	GMappedFile *mfile;
+	GTypelib *typelib;
+	const gchar *ns;
+	GError *error = NULL;
+
+	lib_dir = vinagre_dirs_get_vinagre_lib_dir ();
+	filename = g_build_filename (lib_dir,
+				     "girepository-1.0",
+				     "Vinagre-3.0.typelib",
+				     NULL);
+
+	vinagre_debug_message (DEBUG_PLUGINS, "typelib: %s", filename);
+	mfile = g_mapped_file_new (filename, FALSE, NULL);
+
+	g_free (filename);
+
+	if (mfile == NULL)
+	{
+		g_warning ("Private typelib 'Vinagre-3.0' not found");
+		return;
+	}
+
+	typelib = g_typelib_new_from_mapped_file (mfile, &error);
+
+	if (typelib == NULL)
+	{
+		g_warning ("Private typelib 'Vinagre-3.0' could not be loaded: %s",
+		           error->message);
+
+		g_error_free (error);
+		return;
+	}
+
+	ns = g_irepository_load_typelib (g_irepository_get_default (),
+					 typelib,
+					 0,
+					 &error);
+
+	if (!ns)
+	{
+		g_warning ("Typelib 'Vinagre-3.0' could not be loaded: %s",
+		           error->message);
+		g_error_free (error);
+		return;
+	}
+
+	vinagre_debug_message (DEBUG_PLUGINS, "Namespace '%s' loaded.", ns);
+}
+*/
+
+VinagrePluginsEngine *
+vinagre_plugins_engine_get_default (void)
+{
+  gchar *modules_dir, **search_paths;
+  GError *error;
+
+  if (default_engine != NULL)
+    return default_engine;
+
+
+  /* This should be moved to libpeas */
+  g_irepository_require (g_irepository_get_default (),
+			 "Peas", "1.0", 0, NULL);
+  g_irepository_require (g_irepository_get_default (),
+			 "PeasUI", "1.0", 0, NULL);
+
+  error = NULL;
+  g_irepository_require (g_irepository_get_default (),
+			 "Vinagre", "3.0", 0, &error);
+  if (error)
+    {
+      g_print ("error registering vinagre typelib: %s\n", error->message);
+      g_error_free (error);
+    }
+//  require_private_typelib ();
+
+  modules_dir = vinagre_dirs_get_vinagre_lib_dir ();
+
+  search_paths = g_new (gchar *, 5);
+  /* Add the user plugins dir in ~ */
+  search_paths[0] = vinagre_dirs_get_user_plugins_dir ();
+  search_paths[1] = vinagre_dirs_get_user_plugins_dir ();
+  /* Add the system plugins dir */
+  search_paths[2] = vinagre_dirs_get_vinagre_plugins_dir ();
+  search_paths[3] = vinagre_dirs_get_vinagre_plugins_dir ();
+  /* Add the trailing NULL */
+  search_paths[4] = NULL;
+
+  default_engine = VINAGRE_PLUGINS_ENGINE (g_object_new (VINAGRE_TYPE_PLUGINS_ENGINE,
+							 "app-name", "Vinagre",
+							 "base-module-dir", modules_dir,
+							 "search-paths", search_paths,
+							 NULL));
+
+  g_strfreev (search_paths);
+  g_free (modules_dir);
+
+  g_object_add_weak_pointer (G_OBJECT (default_engine),
+			     (gpointer) &default_engine);
+
+  //vinagre_plugins_engine_active_plugins_changed (default_engine);
+
+  return default_engine;
+}
+
+/*
+void
+vinagre_plugins_engine_active_plugins_changed (VinagrePluginsEngine *engine)
+{
+  gchar **loaded_plugins;
+
+  loaded_plugins = g_settings_get_strv (engine->priv->plugin_settings,
+					VINAGRE_SETTINGS_ACTIVE_PLUGINS);
+
+  engine->priv->loading_plugin_list = TRUE;
+  peas_engine_set_loaded_plugins (PEAS_ENGINE (engine),
+				  (const gchar **) loaded_plugins);
+  engine->priv->loading_plugin_list = FALSE;
+  g_strfreev (loaded_plugins);
+}
+*/
+
+VinagreProtocolExt *
+vinagre_plugins_engine_get_plugin_by_protocol (VinagrePluginsEngine *engine,
+					       const gchar          *protocol)
+{
+  g_return_val_if_fail (VINAGRE_IS_PLUGINS_ENGINE (engine), NULL);
+
+  return g_hash_table_lookup (engine->priv->protocols, (gconstpointer) protocol);
+}
+
+GHashTable *
+vinagre_plugins_engine_get_plugins_by_protocol (VinagrePluginsEngine *engine)
+{
+  g_return_val_if_fail (VINAGRE_IS_PLUGINS_ENGINE (engine), NULL);
+
+  return engine->priv->protocols;
+}
+
+/* ex:set ts=8 noet: */
diff --git a/vinagre/vinagre-plugins-engine.h b/vinagre/vinagre-plugins-engine.h
new file mode 100644
index 0000000..78b343f
--- /dev/null
+++ b/vinagre/vinagre-plugins-engine.h
@@ -0,0 +1,62 @@
+/*
+ * vinagre-plugins-engine.h
+ * This file is part of vinagre
+ *
+ * Copyright (C) 2010 Jonh Wendell <wendell bani com br>
+ *
+ * vinagre-plugins-engine.h is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * vinagre-plugins-engine.h is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __VINAGRE_PLUGINS_ENGINE_H__
+#define __VINAGRE_PLUGINS_ENGINE_H__
+
+#include <glib.h>
+#include <libpeas/peas.h>
+#include "vinagre-protocol-ext.h"
+
+G_BEGIN_DECLS
+
+#define VINAGRE_TYPE_PLUGINS_ENGINE              (vinagre_plugins_engine_get_type ())
+#define VINAGRE_PLUGINS_ENGINE(obj)              (G_TYPE_CHECK_INSTANCE_CAST((obj), VINAGRE_TYPE_PLUGINS_ENGINE, VinagrePluginsEngine))
+#define VINAGRE_PLUGINS_ENGINE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass), VINAGRE_TYPE_PLUGINS_ENGINE, VinagrePluginsEngineClass))
+#define VINAGRE_IS_PLUGINS_ENGINE(obj)           (G_TYPE_CHECK_INSTANCE_TYPE((obj), VINAGRE_TYPE_PLUGINS_ENGINE))
+#define VINAGRE_IS_PLUGINS_ENGINE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), VINAGRE_TYPE_PLUGINS_ENGINE))
+#define VINAGRE_PLUGINS_ENGINE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS((obj), VINAGRE_TYPE_PLUGINS_ENGINE, VinagrePluginsEngineClass))
+
+typedef struct _VinagrePluginsEngine		VinagrePluginsEngine;
+typedef struct _VinagrePluginsEnginePrivate	VinagrePluginsEnginePrivate;
+typedef struct _VinagrePluginsEngineClass	VinagrePluginsEngineClass;
+
+struct _VinagrePluginsEngine
+{
+  PeasEngine parent;
+  VinagrePluginsEnginePrivate *priv;
+};
+
+struct _VinagrePluginsEngineClass
+{
+  PeasEngineClass parent_class;
+};
+
+GType			 vinagre_plugins_engine_get_type	(void) G_GNUC_CONST;
+
+VinagrePluginsEngine	*vinagre_plugins_engine_get_default	(void);
+VinagreProtocolExt	*vinagre_plugins_engine_get_plugin_by_protocol	(VinagrePluginsEngine *engine,
+									 const gchar          *protocol);
+GHashTable		*vinagre_plugins_engine_get_plugins_by_protocol	(VinagrePluginsEngine *engine);
+G_END_DECLS
+
+#endif  /* __VINAGRE_PLUGINS_ENGINE_H__ */
+
+/* vim: set ts=8: */
diff --git a/vinagre/vinagre-protocol-ext.c b/vinagre/vinagre-protocol-ext.c
new file mode 100644
index 0000000..5838862
--- /dev/null
+++ b/vinagre/vinagre-protocol-ext.c
@@ -0,0 +1,191 @@
+/*
+ * vinagre-protocol-ext.c
+ * This file is part of vinagre
+ *
+ * Copyright (C) 2010 Jonh Wendell <wendell bani com br>
+ * 
+ * vinagre-protocol.c is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * vinagre-protocol.h is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "vinagre-protocol-ext.h"
+
+const gchar *
+vinagre_protocol_ext_get_protocol (VinagreProtocolExt *protocol)
+{
+  const gchar *result = NULL;
+
+//  g_return_if_fail (peas_extension_get_type (protocol) != VINAGRE_TYPE_PROTOCOL);
+
+  peas_extension_call (protocol, "get_protocol", &result);
+
+  return result;
+}
+
+gchar **
+vinagre_protocol_ext_get_public_description (VinagreProtocolExt *protocol)
+{
+  gchar **result = NULL;
+
+//  g_return_if_fail (peas_extension_get_type (protocol) != VINAGRE_TYPE_PROTOCOL);
+
+  peas_extension_call (protocol, "get_public_description", &result);
+
+  return result;
+}
+
+gint
+vinagre_protocol_ext_get_default_port (VinagreProtocolExt *protocol)
+{
+  gint result = 0;
+
+//  g_return_if_fail (peas_extension_get_type (protocol) != VINAGRE_TYPE_PROTOCOL);
+
+  peas_extension_call (protocol, "get_default_port", &result);
+
+  return result;
+}
+
+const gchar *
+vinagre_protocol_ext_get_mdns_service (VinagreProtocolExt *protocol)
+{
+  const gchar *result = NULL;
+
+//  g_return_if_fail (peas_extension_get_type (protocol) != VINAGRE_TYPE_PROTOCOL);
+
+  peas_extension_call (protocol, "get_mdns_service", &result);
+
+  return result;
+}
+
+GSList *
+vinagre_protocol_ext_get_context_groups (VinagreProtocolExt *protocol)
+{
+  GSList *result = NULL;
+
+//  g_return_if_fail (peas_extension_get_type (protocol) != VINAGRE_TYPE_PROTOCOL);
+
+  peas_extension_call (protocol, "get_context_groups", &result);
+
+  return result;
+}
+
+GtkFileFilter *
+vinagre_protocol_ext_get_file_filter (VinagreProtocolExt *protocol)
+{
+  GtkFileFilter *result = NULL;
+
+//  g_return_if_fail (peas_extension_get_type (protocol) != VINAGRE_TYPE_PROTOCOL);
+
+  peas_extension_call (protocol, "get_file_filter", &result);
+
+  return result;
+}
+
+GtkWidget *
+vinagre_protocol_ext_new_tab (VinagreProtocolExt *protocol,
+			      VinagreConnection  *conn,
+			      VinagreWindow      *window)
+{
+  GtkWidget *result = NULL;
+
+//  g_return_if_fail (peas_extension_get_type (protocol) != VINAGRE_TYPE_PROTOCOL);
+
+  peas_extension_call (protocol, "new_tab", conn, window, &result);
+
+  return result;
+}
+
+VinagreConnection *
+vinagre_protocol_ext_new_connection (VinagreProtocolExt *protocol)
+{
+  VinagreConnection *result = NULL;
+
+  //g_return_if_fail (peas_extension_get_type (protocol) != VINAGRE_TYPE_PROTOCOL);
+
+  peas_extension_call (protocol, "new_connection", &result);
+
+  return result;
+}
+
+VinagreConnection *
+vinagre_protocol_ext_new_connection_from_file (VinagreProtocolExt *protocol,
+					       const gchar        *data,
+					       gboolean           use_bookmarks,
+					       gchar              **error_msg)
+{
+  VinagreConnection *result = NULL;
+
+  //g_return_if_fail (peas_extension_get_type (protocol) != VINAGRE_TYPE_PROTOCOL);
+
+  peas_extension_call (protocol, "new_connection_from_file", data, use_bookmarks, error_msg, &result);
+
+  return result;
+}
+
+/**
+ * vinagre_protocol_ext_get_connect_widget:
+ *
+ * @protocol: a protocol
+ * @initial_settings: (allow-none): bla bla
+ * @returns: (allow-none): a widget
+ */
+GtkWidget *
+vinagre_protocol_ext_get_connect_widget (VinagreProtocolExt *protocol,
+					 VinagreConnection  *initial_settings)
+{
+  GtkWidget *result = NULL;
+
+  //g_return_if_fail (peas_extension_get_type (protocol) != VINAGRE_TYPE_PROTOCOL);
+
+  peas_extension_call (protocol, "get_connect_widget", initial_settings, &result);
+
+  return result;
+}
+
+void
+vinagre_protocol_ext_parse_mdns_dialog (VinagreProtocolExt *protocol,
+					GtkWidget          *connect_widget,
+					GtkWidget          *dialog)
+{
+  //g_return_if_fail (peas_extension_get_type (protocol) != VINAGRE_TYPE_PROTOCOL);
+
+  peas_extension_call (protocol, "parse_mdns_dialog", connect_widget, dialog);
+}
+
+const gchar *
+vinagre_protocol_ext_get_icon_name (VinagreProtocolExt *protocol)
+{
+  const gchar *result = NULL;
+
+  //g_return_if_fail (peas_extension_get_type (protocol) != VINAGRE_TYPE_PROTOCOL);
+
+  peas_extension_call (protocol, "get_icon_name", &result);
+
+  return result;
+}
+
+GdkPixbuf *
+vinagre_protocol_ext_get_icon (VinagreProtocolExt *protocol,
+			       gint                size)
+{
+  GdkPixbuf *result = NULL;
+
+  //g_return_if_fail (peas_extension_get_type (protocol) != VINAGRE_TYPE_PROTOCOL);
+
+  peas_extension_call (protocol, "get_icon", size, &result);
+
+  return result;
+}
+
+/* vim: set ts=8: */
diff --git a/vinagre/vinagre-protocol-ext.h b/vinagre/vinagre-protocol-ext.h
new file mode 100644
index 0000000..d9014e4
--- /dev/null
+++ b/vinagre/vinagre-protocol-ext.h
@@ -0,0 +1,60 @@
+/*
+ * vinagre-protocol-ext.h
+ * This file is part of vinagre
+ *
+ * Copyright (C) 2010 Jonh Wendell <wendell bani com br>
+ * 
+ * vinagre-protocol.h is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * vinagre-protocol.h is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __VINAGRE_PROTOCOL_EXT_H__
+#define __VINAGRE_PROTOCOL_EXT_H__
+
+#include <glib-object.h>
+#include <libpeas/peas.h>
+#include "vinagre-window.h"
+
+typedef PeasExtension VinagreProtocolExt;
+
+G_BEGIN_DECLS
+
+void		    vinagre_protocol_ext_parse_mdns_dialog	  (VinagreProtocolExt *protocol,
+								   GtkWidget          *connect_widget,
+								   GtkWidget          *dialog);
+GSList *	    vinagre_protocol_ext_get_context_groups	  (VinagreProtocolExt *protocol);
+const gchar *       vinagre_protocol_ext_get_protocol		  (VinagreProtocolExt *protocol);
+gchar **	    vinagre_protocol_ext_get_public_description	  (VinagreProtocolExt *protocol);
+gint		    vinagre_protocol_ext_get_default_port	  (VinagreProtocolExt *protocol);
+VinagreConnection * vinagre_protocol_ext_new_connection		  (VinagreProtocolExt *protocol);
+VinagreConnection * vinagre_protocol_ext_new_connection_from_file (VinagreProtocolExt *protocol,
+								   const gchar        *data,
+								   gboolean           use_bookmarks,
+								   gchar              **error_msg);
+const gchar *	    vinagre_protocol_ext_get_mdns_service	  (VinagreProtocolExt *protocol);
+GtkWidget *	    vinagre_protocol_ext_new_tab		  (VinagreProtocolExt   *protocol,
+								   VinagreConnection *conn,
+								   VinagreWindow     *window);
+GtkWidget *	    vinagre_protocol_ext_get_connect_widget	  (VinagreProtocolExt   *protocol,
+								   VinagreConnection *initial_settings);
+GtkFileFilter *	    vinagre_protocol_ext_get_file_filter	  (VinagreProtocolExt *protocol);
+
+GdkPixbuf *	    vinagre_protocol_ext_get_icon		  (VinagreProtocolExt *protocol,
+								   gint               size);
+const gchar *	    vinagre_protocol_ext_get_icon_name		  (VinagreProtocolExt *protocol);
+
+G_END_DECLS
+
+#endif  /* __VINAGRE_PROTOCOL_EXT_H__ */
+
+/* vim: set ts=8: */
diff --git a/vinagre/vinagre-protocol.c b/vinagre/vinagre-protocol.c
new file mode 100644
index 0000000..b42f18c
--- /dev/null
+++ b/vinagre/vinagre-protocol.c
@@ -0,0 +1,352 @@
+/*
+ * vinagre-protocol.c
+ * This file is part of vinagre
+ *
+ * Copyright (C) 2010 Jonh Wendell <wendell bani com br>
+ * 
+ * vinagre-protocol.c is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * vinagre-protocol.h is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "vinagre-protocol.h"
+
+G_DEFINE_INTERFACE (VinagreProtocol, vinagre_protocol, G_TYPE_OBJECT)
+
+static const gchar *
+dummy (VinagreProtocol *protocol)
+{
+  return NULL;
+}
+
+static gchar **
+default_get_public_description (VinagreProtocol *protocol)
+{
+  return NULL;
+}
+
+static gint
+default_get_default_port (VinagreProtocol *protocol)
+{
+  return 0;
+}
+
+static GSList *
+default_get_context_groups (VinagreProtocol *protocol)
+{
+  return NULL;
+}
+
+static GtkFileFilter *
+default_get_file_filter (VinagreProtocol *protocol)
+{
+  return NULL;
+}
+
+static GtkWidget *
+default_new_tab (VinagreProtocol   *protocol,
+		 VinagreConnection *conn,
+		 VinagreWindow     *window)
+{
+  return NULL;
+}
+
+static VinagreConnection *
+default_new_connection (VinagreProtocol *protocol)
+{
+  return NULL;
+}
+
+static VinagreConnection *
+default_new_connection_from_file (VinagreProtocol *protocol,
+				  const gchar     *data,
+				  gboolean         use_bookmarks,
+				  gchar           **error_msg)
+{
+  return NULL;
+}
+
+static GtkWidget *
+default_get_connect_widget (VinagreProtocol   *protocol,
+			    VinagreConnection *initial_settings)
+{
+  return NULL;
+}
+
+static void
+default_parse_mdns_dialog (VinagreProtocol *protocol,
+			   GtkWidget       *connect_widget,
+			   GtkWidget       *dialog)
+{
+}
+
+static GdkPixbuf *
+default_get_icon (VinagreProtocol *protocol,
+		  gint             size)
+{
+  return NULL;
+}
+
+void
+vinagre_protocol_default_init (VinagreProtocolInterface *iface)
+{
+  iface->get_protocol = dummy;
+  iface->get_public_description = default_get_public_description;
+  iface->get_default_port = default_get_default_port;
+  iface->get_mdns_service = dummy;
+  iface->get_context_groups = default_get_context_groups;
+  iface->get_file_filter = default_get_file_filter;
+  iface->new_tab = default_new_tab;
+  iface->new_connection = default_new_connection;
+  iface->new_connection_from_file = default_new_connection_from_file;
+  iface->get_connect_widget = default_get_connect_widget;
+  iface->parse_mdns_dialog = default_parse_mdns_dialog;
+  iface->get_icon_name = dummy;
+  iface->get_icon = default_get_icon;
+}
+
+const gchar *
+vinagre_protocol_get_protocol (VinagreProtocol *protocol)
+{
+  VinagreProtocolInterface *iface;
+
+  g_return_val_if_fail (VINAGRE_IS_PROTOCOL (protocol), NULL);
+
+  iface = VINAGRE_PROTOCOL_GET_IFACE (protocol);
+
+  if (iface->get_protocol != NULL)
+    {
+      return iface->get_protocol (protocol);
+    }
+
+  return NULL;
+}
+
+gchar **
+vinagre_protocol_get_public_description (VinagreProtocol *protocol)
+{
+  VinagreProtocolInterface *iface;
+
+  g_return_val_if_fail (VINAGRE_IS_PROTOCOL (protocol), NULL);
+
+  iface = VINAGRE_PROTOCOL_GET_IFACE (protocol);
+
+  if (iface->get_public_description != NULL)
+    {
+      return iface->get_public_description (protocol);
+    }
+
+  return NULL;
+}
+
+gint
+vinagre_protocol_get_default_port (VinagreProtocol *protocol)
+{
+  VinagreProtocolInterface *iface;
+
+  g_return_val_if_fail (VINAGRE_IS_PROTOCOL (protocol), 0);
+
+  iface = VINAGRE_PROTOCOL_GET_IFACE (protocol);
+
+  if (iface->get_default_port != NULL)
+    {
+      return iface->get_default_port (protocol);
+    }
+
+  return 0;
+}
+
+const gchar *
+vinagre_protocol_get_mdns_service (VinagreProtocol *protocol)
+{
+  VinagreProtocolInterface *iface;
+
+  g_return_val_if_fail (VINAGRE_IS_PROTOCOL (protocol), NULL);
+
+  iface = VINAGRE_PROTOCOL_GET_IFACE (protocol);
+
+  if (iface->get_mdns_service != NULL)
+    {
+      return iface->get_mdns_service (protocol);
+    }
+
+  return NULL;
+}
+
+GSList *
+vinagre_protocol_get_context_groups (VinagreProtocol *protocol)
+{
+  VinagreProtocolInterface *iface;
+
+  g_return_val_if_fail (VINAGRE_IS_PROTOCOL (protocol), NULL);
+
+  iface = VINAGRE_PROTOCOL_GET_IFACE (protocol);
+
+  if (iface->get_context_groups != NULL)
+    {
+      return iface->get_context_groups (protocol);
+    }
+
+  return NULL;
+}
+
+GtkFileFilter *
+vinagre_protocol_get_file_filter (VinagreProtocol *protocol)
+{
+  VinagreProtocolInterface *iface;
+
+  g_return_val_if_fail (VINAGRE_IS_PROTOCOL (protocol), NULL);
+
+  iface = VINAGRE_PROTOCOL_GET_IFACE (protocol);
+
+  if (iface->get_file_filter != NULL)
+    {
+      return iface->get_file_filter (protocol);
+    }
+
+  return NULL;
+}
+
+GtkWidget *
+vinagre_protocol_new_tab (VinagreProtocol   *protocol,
+			  VinagreConnection *conn,
+			  VinagreWindow     *window)
+{
+  VinagreProtocolInterface *iface;
+
+  g_return_val_if_fail (VINAGRE_IS_PROTOCOL (protocol), NULL);
+
+  iface = VINAGRE_PROTOCOL_GET_IFACE (protocol);
+
+  if (iface->new_tab != NULL)
+    {
+      return iface->new_tab (protocol, conn, window);
+    }
+
+  return NULL;
+}
+
+VinagreConnection *
+vinagre_protocol_new_connection (VinagreProtocol *protocol)
+{
+  VinagreProtocolInterface *iface;
+
+  g_return_val_if_fail (VINAGRE_IS_PROTOCOL (protocol), NULL);
+
+  iface = VINAGRE_PROTOCOL_GET_IFACE (protocol);
+
+  if (iface->new_connection != NULL)
+    {
+      return iface->new_connection (protocol);
+    }
+
+  return NULL;
+}
+
+VinagreConnection *
+vinagre_protocol_new_connection_from_file (VinagreProtocol *protocol,
+					   const gchar     *data,
+					   gboolean         use_bookmarks,
+					   gchar           **error_msg)
+{
+  VinagreProtocolInterface *iface;
+
+  g_return_val_if_fail (VINAGRE_IS_PROTOCOL (protocol), NULL);
+
+  iface = VINAGRE_PROTOCOL_GET_IFACE (protocol);
+
+  if (iface->new_connection_from_file != NULL)
+    {
+      return iface->new_connection_from_file (protocol, data, use_bookmarks, error_msg);
+    }
+
+  return NULL;
+}
+
+/**
+ * vinagre_protocol_get_connect_widget:
+ *
+ * @protocol: a protocol
+ * @initial_settings: (allow-none): bla bla
+ * @returns: (allow-none): a widget
+ */
+GtkWidget *
+vinagre_protocol_get_connect_widget (VinagreProtocol   *protocol,
+				     VinagreConnection *initial_settings)
+{
+  VinagreProtocolInterface *iface;
+
+  g_return_val_if_fail (VINAGRE_IS_PROTOCOL (protocol), NULL);
+
+  iface = VINAGRE_PROTOCOL_GET_IFACE (protocol);
+
+  if (iface->get_connect_widget != NULL)
+    {
+      return iface->get_connect_widget (protocol, initial_settings);
+    }
+
+  return NULL;
+}
+
+void
+vinagre_protocol_parse_mdns_dialog (VinagreProtocol *protocol,
+				    GtkWidget       *connect_widget,
+				    GtkWidget       *dialog)
+{
+  VinagreProtocolInterface *iface;
+
+  g_return_if_fail (VINAGRE_IS_PROTOCOL (protocol));
+
+  iface = VINAGRE_PROTOCOL_GET_IFACE (protocol);
+
+  if (iface->parse_mdns_dialog != NULL)
+    {
+      iface->parse_mdns_dialog (protocol, connect_widget, dialog);
+    }
+}
+
+const gchar *
+vinagre_protocol_get_icon_name (VinagreProtocol *protocol)
+{
+  VinagreProtocolInterface *iface;
+
+  g_return_val_if_fail (VINAGRE_IS_PROTOCOL (protocol), NULL);
+
+  iface = VINAGRE_PROTOCOL_GET_IFACE (protocol);
+
+  if (iface->get_icon_name != NULL)
+    {
+      return iface->get_icon_name (protocol);
+    }
+
+  return NULL;
+}
+
+GdkPixbuf *
+vinagre_protocol_get_icon (VinagreProtocol *protocol,
+			   gint             size)
+{
+  VinagreProtocolInterface *iface;
+
+  g_return_val_if_fail (VINAGRE_IS_PROTOCOL (protocol), NULL);
+
+  iface = VINAGRE_PROTOCOL_GET_IFACE (protocol);
+
+  if (iface->get_icon != NULL)
+    {
+      return iface->get_icon (protocol, size);
+    }
+
+  return NULL;
+}
+
+/* vim: set ts=8: */
diff --git a/vinagre/vinagre-protocol.h b/vinagre/vinagre-protocol.h
new file mode 100644
index 0000000..fa61c0e
--- /dev/null
+++ b/vinagre/vinagre-protocol.h
@@ -0,0 +1,104 @@
+/*
+ * vinagre-protocol.h
+ * This file is part of vinagre
+ *
+ * Copyright (C) 2010 Jonh Wendell <wendell bani com br>
+ * 
+ * vinagre-protocol.h is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * vinagre-protocol.h is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __VINAGRE_PROTOCOL_H__
+#define __VINAGRE_PROTOCOL_H__
+
+#include <glib-object.h>
+#include <libpeas/peas.h>
+
+#include "vinagre-window.h"
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define VINAGRE_TYPE_PROTOCOL              (vinagre_protocol_get_type())
+#define VINAGRE_PROTOCOL(obj)              (G_TYPE_CHECK_INSTANCE_CAST((obj), VINAGRE_TYPE_PROTOCOL, VinagreProtocol))
+#define VINAGRE_PROTOCOL_IFACE(klass)      (G_TYPE_CHECK_IFACE_CAST((klass), VINAGRE_TYPE_PROTOCOL, VinagreProtocolInterface))
+#define VINAGRE_IS_PROTOCOL(obj)           (G_TYPE_CHECK_INSTANCE_TYPE((obj), VINAGRE_TYPE_PROTOCOL))
+#define VINAGRE_IS_PROTOCOL_IFACE(klass)   (G_TYPE_CHECK_IFACE_TYPE ((klass), VINAGRE_TYPE_PROTOCOL))
+#define VINAGRE_PROTOCOL_GET_IFACE(obj)    (G_TYPE_INSTANCE_GET_INTERFACE((obj), VINAGRE_TYPE_PROTOCOL, VinagreProtocolInterface))
+
+typedef struct _VinagreProtocol VinagreProtocol;
+typedef struct _VinagreProtocolInterface VinagreProtocolInterface;
+
+struct _VinagreProtocolInterface
+{
+  GTypeInterface g_iface;
+
+  /* Virtual public methods */
+  GSList		*(*get_context_groups)		(VinagreProtocol *protocol);
+  const gchar		*(*get_protocol)		(VinagreProtocol *protocol);
+  gchar			**(*get_public_description)	(VinagreProtocol *protocol);
+  gint			(*get_default_port)		(VinagreProtocol *protocol);
+  VinagreConnection	*(*new_connection)		(VinagreProtocol *protocol);
+  VinagreConnection	*(*new_connection_from_file)	(VinagreProtocol *protocol,
+							 const gchar     *data,
+							 gboolean         use_bookmarks,
+							 gchar          **error_msg);
+  const gchar		*(*get_mdns_service)		(VinagreProtocol *protocol);
+  GtkWidget 		*(*new_tab)			(VinagreProtocol   *protocol,
+							 VinagreConnection *conn,
+							 VinagreWindow     *window);
+  GtkWidget 		*(*get_connect_widget)		(VinagreProtocol   *protocol,
+							 VinagreConnection *initial_settings);
+  void			(*parse_mdns_dialog)		(VinagreProtocol *protocol,
+							 GtkWidget       *connect_widget,
+							 GtkWidget       *dialog);
+  GtkFileFilter		*(*get_file_filter)		(VinagreProtocol *protocol);
+  GdkPixbuf		*(*get_icon)			(VinagreProtocol *protocol,
+							 gint             size);
+  const gchar		*(*get_icon_name)		(VinagreProtocol *protocol);
+};
+
+/*
+ * Public methods
+ */
+GType			vinagre_protocol_get_type		  (void) G_GNUC_CONST;
+
+void			vinagre_protocol_parse_mdns_dialog	  (VinagreProtocol *protocol,
+								   GtkWidget *connect_widget,
+								   GtkWidget *dialog);
+GSList *		vinagre_protocol_get_context_groups	  (VinagreProtocol *protocol);
+const gchar *		vinagre_protocol_get_protocol		  (VinagreProtocol *protocol);
+gchar **		vinagre_protocol_get_public_description	  (VinagreProtocol *protocol);
+gint			vinagre_protocol_get_default_port	  (VinagreProtocol *protocol);
+VinagreConnection *	vinagre_protocol_new_connection		  (VinagreProtocol *protocol);
+VinagreConnection *	vinagre_protocol_new_connection_from_file (VinagreProtocol *protocol,
+								   const gchar     *data,
+								   gboolean         use_bookmarks,
+								   gchar           **error_msg);
+const gchar *		vinagre_protocol_get_mdns_service	  (VinagreProtocol *protocol);
+
+GtkWidget *		vinagre_protocol_new_tab		  (VinagreProtocol   *protocol,
+								   VinagreConnection *conn,
+								   VinagreWindow     *window);
+GtkWidget *		vinagre_protocol_get_connect_widget	  (VinagreProtocol   *protocol,
+								   VinagreConnection *initial_settings);
+GtkFileFilter *		vinagre_protocol_get_file_filter	  (VinagreProtocol *protocol);
+
+GdkPixbuf *		vinagre_protocol_get_icon		  (VinagreProtocol *protocol,
+								   gint             size);
+const gchar *		vinagre_protocol_get_icon_name		  (VinagreProtocol *protocol);
+
+#endif  /* __VINAGRE_PROTOCOL_H__ */
+/* vim: set ts=8: */
diff --git a/vinagre/vinagre-tab.c b/vinagre/vinagre-tab.c
index 89ef902..3dd90f6 100644
--- a/vinagre/vinagre-tab.c
+++ b/vinagre/vinagre-tab.c
@@ -31,7 +31,7 @@
 #include "vinagre-utils.h"
 #include "vinagre-prefs.h"
 #include "view/autoDrawer.h"
-#include "vinagre-plugin.h"
+#include "vinagre-protocol-ext.h"
 #include "vinagre-plugins-engine.h"
 
 #define VINAGRE_TAB_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), VINAGRE_TYPE_TAB, VinagreTabPrivate))
@@ -250,11 +250,11 @@ static void
 active_connections_button_clicked  (GtkToolButton *button,
 				    VinagreTab    *tab)
 {
-  GSList            *connections, *l;
-  VinagrePlugin     *plugin;
-  VinagreConnection *conn;
-  GtkWidget         *menu, *item, *image;
-  gchar             *str, *label;
+  GSList             *connections, *l;
+  VinagreProtocolExt *ext;
+  VinagreConnection  *conn;
+  GtkWidget          *menu, *item, *image;
+  gchar              *str, *label;
 
   menu = gtk_menu_new ();
 
@@ -262,10 +262,10 @@ active_connections_button_clicked  (GtkToolButton *button,
   for (l = connections; l; l = l->next)
     {
       conn = VINAGRE_TAB (l->data)->priv->conn;
-      plugin = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (),
-							      vinagre_connection_get_protocol (conn));
+      ext = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (),
+							   vinagre_connection_get_protocol (conn));
       item = gtk_image_menu_item_new_with_label ("");
-      image = gtk_image_new_from_icon_name (vinagre_plugin_get_icon_name (plugin),
+      image = gtk_image_new_from_icon_name (vinagre_protocol_ext_get_icon_name (ext),
 					    GTK_ICON_SIZE_MENU);
       gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
 
@@ -524,18 +524,17 @@ vinagre_tab_init (VinagreTab *tab)
 GtkWidget *
 vinagre_tab_new (VinagreConnection *conn, VinagreWindow *window)
 {
-  VinagrePlugin *plugin;
-  const gchar   *protocol = vinagre_connection_get_protocol (conn);
+  VinagreProtocolExt *ext;
+  const gchar *protocol = vinagre_connection_get_protocol (conn);
 
-  plugin = g_hash_table_lookup (vinagre_plugin_engine_get_plugins_by_protocol (vinagre_plugins_engine_get_default ()),
-				protocol);
-  if (!plugin)
+  ext = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (), protocol);
+  if (!ext)
     {
       g_warning (_("The protocol %s is not supported."), protocol);
       return NULL;
     }
 
-  return vinagre_plugin_new_tab (plugin, conn, window);
+  return vinagre_protocol_ext_new_tab (ext, conn, window);
 }
 
 gchar *
@@ -938,17 +937,16 @@ vinagre_tab_free_actions (GSList *actions)
 const gchar *
 vinagre_tab_get_icon_name (VinagreTab *tab)
 {
-  const gchar   *protocol;
-  VinagrePlugin *plugin;
+  const gchar *protocol;
+  VinagreProtocolExt *ext;
 
   g_return_val_if_fail (VINAGRE_IS_TAB (tab), NULL);
 
   protocol = vinagre_connection_get_protocol (tab->priv->conn);
-  plugin = g_hash_table_lookup (vinagre_plugin_engine_get_plugins_by_protocol (vinagre_plugins_engine_get_default ()),
-				protocol);
-  g_return_val_if_fail (plugin != NULL, NULL);
+  ext = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (), protocol);
+  g_return_val_if_fail (ext != NULL, NULL);
 
-  return vinagre_plugin_get_icon_name (plugin);
+  return vinagre_protocol_ext_get_icon_name (ext);
 }
 
 /* vim: set ts=8: */
diff --git a/vinagre/vinagre-utils.c b/vinagre/vinagre-utils.c
index 95201f9..1ebf294 100644
--- a/vinagre/vinagre-utils.c
+++ b/vinagre/vinagre-utils.c
@@ -141,7 +141,7 @@ vinagre_utils_get_ui_xml_filename (void)
  *  if the file cannot be found. In this case an error dialog will be shown.
  */
 GtkBuilder *
-vinagre_utils_get_builder (VinagrePlugin *plugin, const gchar *filename)
+vinagre_utils_get_builder (void *plugin, const gchar *filename)
 {
   GtkBuilder *xml = NULL;
   GError     *error = NULL;
@@ -149,7 +149,7 @@ vinagre_utils_get_builder (VinagrePlugin *plugin, const gchar *filename)
 
   if (plugin)
     {
-      plugin_datadir = vinagre_plugin_get_data_dir (plugin);
+      //plugin_datadir = vinagre_plugin_get_data_dir (plugin);
       actual_filename = g_build_filename (plugin_datadir, filename, NULL);
       g_free (plugin_datadir);
     }
diff --git a/vinagre/vinagre-utils.h b/vinagre/vinagre-utils.h
index 6b66ad1..8a10a90 100644
--- a/vinagre/vinagre-utils.h
+++ b/vinagre/vinagre-utils.h
@@ -23,7 +23,6 @@
 
 #include <gtk/gtk.h>
 #include <glib.h>
-#include "vinagre-plugin.h"
 
 /* useful macro */
 #define GBOOLEAN_TO_POINTER(i) ((gpointer) ((i) ? 2 : 1))
@@ -46,7 +45,7 @@ void		vinagre_utils_toggle_widget_visible	(GtkWidget *widget);
 
 const gchar	*vinagre_utils_get_ui_filename		(void);
 const gchar	*vinagre_utils_get_ui_xml_filename	(void);
-GtkBuilder	*vinagre_utils_get_builder		(VinagrePlugin *plugin, const gchar *filename);
+GtkBuilder	*vinagre_utils_get_builder		(void *plugin, const gchar *filename);
 
 gchar		*vinagre_utils_escape_underscores	(const gchar *text,
 							 gssize      length);
diff --git a/vinagre/vinagre-window.c b/vinagre/vinagre-window.c
index 1da0e98..9f011d0 100644
--- a/vinagre/vinagre-window.c
+++ b/vinagre/vinagre-window.c
@@ -42,7 +42,7 @@
 #include "vinagre-ui.h"
 #include "vinagre-window-private.h"
 #include "vinagre-bookmarks-entry.h"
-#include "vinagre-plugin.h"
+#include "vinagre-protocol-ext.h"
 #include "vinagre-plugins-engine.h"
 #include "vinagre-dirs.h"
 
@@ -63,8 +63,7 @@ vinagre_window_dispose (GObject *object)
 
   if (!window->priv->dispose_has_run)
     {
-      vinagre_plugins_engine_deactivate_plugins (vinagre_plugins_engine_get_default (),
-						 window);
+      peas_engine_garbage_collect (PEAS_ENGINE (vinagre_plugins_engine_get_default ()));
       window->priv->dispose_has_run = TRUE;
     }
 
@@ -495,7 +494,7 @@ vinagre_window_populate_bookmarks (VinagreWindow *window,
   GtkAction             *action;
   VinagreWindowPrivate  *p = window->priv;
   VinagreConnection     *conn;
-  VinagrePlugin         *plugin;
+  VinagreProtocolExt    *ext;
 
   for (l = entries; l; l = l->next)
     {
@@ -533,8 +532,8 @@ vinagre_window_populate_bookmarks (VinagreWindow *window,
 
 	  case VINAGRE_BOOKMARKS_ENTRY_NODE_CONN:
 	    conn = vinagre_bookmarks_entry_get_conn (entry);
-	    plugin = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (),
-								    vinagre_connection_get_protocol (conn));
+	    ext = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (),
+								 vinagre_connection_get_protocol (conn));
 
 	    action_name = vinagre_connection_get_best_name (conn);
 	    action_label = vinagre_utils_escape_underscores (action_name, -1);
@@ -552,7 +551,7 @@ vinagre_window_populate_bookmarks (VinagreWindow *window,
 				     NULL);
 	    g_object_set (G_OBJECT (action),
 			  "icon-name",
-			  vinagre_plugin_get_icon_name (plugin),
+			  vinagre_protocol_ext_get_icon_name (ext),
 			  NULL);
 	    g_object_set_data (G_OBJECT (action), "conn", conn);
 	    gtk_action_group_add_action (p->bookmarks_list_action_group,
@@ -801,10 +800,6 @@ vinagre_window_init (VinagreWindow *window)
                             window);
 #endif
 
-  vinagre_plugins_engine_activate_plugins (vinagre_plugins_engine_get_default (),
-					   window);
-
-
   g_idle_add ((GSourceFunc) vinagre_window_check_first_run, window);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]