summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libnm-core/nm-vpn-editor-plugin.c63
-rw-r--r--libnm-core/nm-vpn-editor-plugin.h8
-rw-r--r--libnm-core/nm-vpn-plugin-info.c3
-rw-r--r--libnm-core/nm-vpn-plugin-info.h4
-rw-r--r--libnm/libnm.ver2
5 files changed, 76 insertions, 4 deletions
diff --git a/libnm-core/nm-vpn-editor-plugin.c b/libnm-core/nm-vpn-editor-plugin.c
index 36ce385425..e49d8b2679 100644
--- a/libnm-core/nm-vpn-editor-plugin.c
+++ b/libnm-core/nm-vpn-editor-plugin.c
@@ -25,6 +25,7 @@
#include "nm-vpn-editor-plugin.h"
#include "nm-core-internal.h"
+#include "nm-vpn-plugin-info.h"
G_DEFINE_INTERFACE (NMVpnEditorPlugin, nm_vpn_editor_plugin, G_TYPE_OBJECT)
@@ -70,12 +71,14 @@ nm_vpn_editor_plugin_default_init (NMVpnEditorPluginInterface *iface)
/******************************************************************************/
typedef struct {
- int dummy;
+ NMVpnPluginInfo *plugin_info;
} NMVpnEditorPluginPrivate;
static void
_nm_vpn_editor_plugin_private_destroy (NMVpnEditorPluginPrivate *priv)
{
+ if (priv->plugin_info)
+ g_object_remove_weak_pointer ((GObject *) priv->plugin_info, (gpointer *) &priv->plugin_info);
g_slice_free (NMVpnEditorPluginPrivate, priv);
}
@@ -306,7 +309,63 @@ nm_vpn_editor_plugin_load (const char *plugin_name,
error);
}
-/*********************************************************************/
+/*****************************************************************************/
+
+/**
+ * nm_vpn_editor_plugin_get_plugin_info:
+ * @self: the #NMVpnEditorPlugin instance
+ *
+ * Returns: the #NMVpnPluginInfo instance, if set.
+ *
+ * Since: 1.4
+ **/
+NMVpnPluginInfo *
+nm_vpn_editor_plugin_get_plugin_info (NMVpnEditorPlugin *self)
+{
+ NMVpnEditorPluginPrivate *priv;
+
+ g_return_val_if_fail (NM_IS_VPN_EDITOR_PLUGIN (self), NULL);
+
+ priv = NM_VPN_EDITOR_PLUGIN_GET_PRIVATE (self);
+ return priv->plugin_info;
+}
+
+/**
+ * nm_vpn_editor_plugin_set_plugin_info:
+ * @self: the #NMVpnEditorPlugin instance
+ * @plugin_info: (allow-none): the plugin info to set.
+ * Set to %NULL to clear.
+ *
+ * Set the plugin info of the editor plugin. This will only take
+ * a weak-ref to the plugin info, because usually the plugin-info
+ * itself already holds a strong reference to the editor-plugin.
+ *
+ * It is save to reset the the plugin-info to another instance or
+ * clear it by setting it to %NULL.
+ *
+ * Since: 1.4
+ **/
+void
+nm_vpn_editor_plugin_set_plugin_info (NMVpnEditorPlugin *self,
+ NMVpnPluginInfo *plugin_info)
+{
+ NMVpnEditorPluginPrivate *priv;
+
+ g_return_if_fail (NM_IS_VPN_EDITOR_PLUGIN (self));
+ g_return_if_fail (!plugin_info || NM_IS_VPN_PLUGIN_INFO (plugin_info));
+
+ priv = NM_VPN_EDITOR_PLUGIN_GET_PRIVATE (self);
+
+ if (priv->plugin_info == plugin_info)
+ return;
+ if (priv->plugin_info)
+ g_object_remove_weak_pointer ((GObject *) priv->plugin_info, (gpointer *) &priv->plugin_info);
+ priv->plugin_info = plugin_info;
+ if (priv->plugin_info)
+ g_object_add_weak_pointer ((GObject *) priv->plugin_info, (gpointer *) &priv->plugin_info);
+}
+
+/*****************************************************************************/
/**
* nm_vpn_editor_plugin_get_editor:
diff --git a/libnm-core/nm-vpn-editor-plugin.h b/libnm-core/nm-vpn-editor-plugin.h
index 82c609b969..e941381a37 100644
--- a/libnm-core/nm-vpn-editor-plugin.h
+++ b/libnm-core/nm-vpn-editor-plugin.h
@@ -123,6 +123,12 @@ typedef struct {
GType nm_vpn_editor_plugin_get_type (void);
+struct _NMVpnPluginInfo;
+
+struct _NMVpnPluginInfo *nm_vpn_editor_plugin_get_plugin_info (NMVpnEditorPlugin *plugin);
+void nm_vpn_editor_plugin_set_plugin_info (NMVpnEditorPlugin *plugin,
+ struct _NMVpnPluginInfo *info);
+
NMVpnEditor *nm_vpn_editor_plugin_get_editor (NMVpnEditorPlugin *plugin,
NMConnection *connection,
GError **error);
@@ -154,4 +160,4 @@ NMVpnEditorPlugin *nm_vpn_editor_plugin_load (const char *plugin_name,
G_END_DECLS
-#endif /* __NM_VPN_EDITOR_PLUGIN_H__ */
+#endif /* __NM_VPN_EDITOR_PLUGIN_H__ */
diff --git a/libnm-core/nm-vpn-plugin-info.c b/libnm-core/nm-vpn-plugin-info.c
index 90099cd0aa..19f24eb545 100644
--- a/libnm-core/nm-vpn-plugin-info.c
+++ b/libnm-core/nm-vpn-plugin-info.c
@@ -900,6 +900,9 @@ nm_vpn_plugin_info_load_editor_plugin (NMVpnPluginInfo *self, GError **error)
NULL,
NULL,
error);
+
+ if (priv->editor_plugin)
+ nm_vpn_editor_plugin_set_plugin_info (priv->editor_plugin, self);
return priv->editor_plugin;
}
diff --git a/libnm-core/nm-vpn-plugin-info.h b/libnm-core/nm-vpn-plugin-info.h
index 9844625cfc..e396066c1c 100644
--- a/libnm-core/nm-vpn-plugin-info.h
+++ b/libnm-core/nm-vpn-plugin-info.h
@@ -44,7 +44,9 @@ G_BEGIN_DECLS
#define NM_VPN_PLUGIN_INFO_KF_GROUP_LIBNM "libnm"
#define NM_VPN_PLUGIN_INFO_KF_GROUP_GNOME "GNOME"
-typedef struct {
+struct _NMVpnPluginInfo;
+
+typedef struct _NMVpnPluginInfo {
NM_AVAILABLE_IN_1_2
GObject parent;
} NMVpnPluginInfo;
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index e40a8d8e2e..32784eef90 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -1066,4 +1066,6 @@ global:
nm_vpn_plugin_info_get_service;
nm_vpn_plugin_info_new_search_file;
nm_vpn_plugin_info_supports_hints;
+ nm_vpn_editor_plugin_get_plugin_info;
+ nm_vpn_editor_plugin_set_plugin_info;
} libnm_1_2_0;