summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-04-20 16:18:05 +0200
committerThomas Haller <thaller@redhat.com>2016-04-22 14:17:02 +0200
commita3f94f451b910bbaf38a172f6bb9a2050a9553e5 (patch)
tree0f188d44e71a373e1b4271a35ad471250cd5b6c9
parent0d95ed3bb8a2bc849c5133232fa8fb6e2409e4fc (diff)
downloadNetworkManager-a3f94f451b910bbaf38a172f6bb9a2050a9553e5.tar.gz
libnm/vpn: add nm_vpn_plugin_info_get_auth_dialog()
-rw-r--r--libnm-core/Makefile.am1
-rw-r--r--libnm-core/nm-vpn-plugin-info.c39
-rw-r--r--libnm-core/nm-vpn-plugin-info.h2
-rw-r--r--libnm/libnm.ver1
4 files changed, 43 insertions, 0 deletions
diff --git a/libnm-core/Makefile.am b/libnm-core/Makefile.am
index c4d348aa75..695b6a3a58 100644
--- a/libnm-core/Makefile.am
+++ b/libnm-core/Makefile.am
@@ -12,6 +12,7 @@ AM_CPPFLAGS = \
-DNMCONFDIR=\"$(nmconfdir)\" \
-DNMLIBDIR=\"$(nmlibdir)\" \
-DNMPLUGINDIR=\"$(pkglibdir)\" \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB \
$(GLIB_CFLAGS) \
$(CODE_COVERAGE_CFLAGS) \
diff --git a/libnm-core/nm-vpn-plugin-info.c b/libnm-core/nm-vpn-plugin-info.c
index c2a71cd266..dae1738bff 100644
--- a/libnm-core/nm-vpn-plugin-info.c
+++ b/libnm-core/nm-vpn-plugin-info.c
@@ -45,6 +45,7 @@ typedef struct {
char *filename;
char *name;
char *service;
+ char *auth_dialog;
char **aliases;
GKeyFile *keyfile;
@@ -595,6 +596,43 @@ nm_vpn_plugin_info_get_service (NMVpnPluginInfo *self)
}
/**
+ * nm_vpn_plugin_info_get_auth_dialog:
+ * @self: plugin info instance
+ *
+ * Returns: the absolute path to the auth-dialog helper or %NULL.
+ *
+ * Since: 1.4
+ **/
+const char *
+nm_vpn_plugin_info_get_auth_dialog (NMVpnPluginInfo *self)
+{
+ NMVpnPluginInfoPrivate *priv;
+
+ g_return_val_if_fail (NM_IS_VPN_PLUGIN_INFO (self), NULL);
+
+ priv = NM_VPN_PLUGIN_INFO_GET_PRIVATE (self);
+
+ if (G_UNLIKELY (priv->auth_dialog == NULL)) {
+ const char *s;
+
+ s = g_hash_table_lookup (priv->keys, _nm_utils_strstrdictkey_static (NM_VPN_PLUGIN_INFO_KF_GROUP_GNOME, "auth-dialog"));
+ if (!s || !s[0])
+ priv->auth_dialog = g_strdup ("");
+ else if (g_path_is_absolute (s))
+ priv->auth_dialog = g_strdup (s);
+ else {
+ gs_free char *prog_basename;
+
+ /* for relative paths, we take the basename and assume it's in LIBEXECDIR. */
+ prog_basename = g_path_get_basename (s);
+ priv->auth_dialog = g_build_filename (LIBEXECDIR, prog_basename, NULL);
+ }
+ }
+
+ return priv->auth_dialog[0] ? priv->auth_dialog : NULL;
+}
+
+/**
* nm_vpn_plugin_info_get_plugin:
* @self: plugin info instance
*
@@ -966,6 +1004,7 @@ finalize (GObject *object)
g_free (priv->name);
g_free (priv->service);
+ g_free (priv->auth_dialog);
g_strfreev (priv->aliases);
g_free (priv->filename);
g_hash_table_unref (priv->keys);
diff --git a/libnm-core/nm-vpn-plugin-info.h b/libnm-core/nm-vpn-plugin-info.h
index 85c21da407..581d5d9c08 100644
--- a/libnm-core/nm-vpn-plugin-info.h
+++ b/libnm-core/nm-vpn-plugin-info.h
@@ -80,6 +80,8 @@ NM_AVAILABLE_IN_1_2
const char *nm_vpn_plugin_info_get_plugin (NMVpnPluginInfo *self);
NM_AVAILABLE_IN_1_2
const char *nm_vpn_plugin_info_get_program (NMVpnPluginInfo *self);
+NM_AVAILABLE_IN_1_4
+const char *nm_vpn_plugin_info_get_auth_dialog (NMVpnPluginInfo *self);
NM_AVAILABLE_IN_1_2
gboolean nm_vpn_plugin_info_supports_multiple (NMVpnPluginInfo *self);
NM_AVAILABLE_IN_1_2
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index 2de830ed63..2e2f3cdd43 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -1062,5 +1062,6 @@ global:
libnm_1_4_0 {
global:
nm_vpn_editor_plugin_load;
+ nm_vpn_plugin_info_get_auth_dialog;
nm_vpn_plugin_info_get_service;
} libnm_1_2_0;