summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2015-11-02 16:04:30 +0100
committerLubomir Rintel <lkundrak@v3.sk>2015-11-02 16:04:30 +0100
commitafa62716c0152cc867eba579c77742cbaa3a3c8b (patch)
tree5f62285728c3d706deaed695ec03fa9754f308df
parentea0e36b61d0054261c94970826829695227de374 (diff)
parentcde053c0b055bf7e306dcdd45ed80d42c894a8ba (diff)
downloadNetworkManager-afa62716c0152cc867eba579c77742cbaa3a3c8b.tar.gz
merge: branch 'lr/vpn-aliases'
https://bugzilla.gnome.org/show_bug.cgi?id=757432
-rw-r--r--libnm-core/nm-vpn-plugin-info.c37
-rw-r--r--libnm-core/nm-vpn-plugin-info.h2
-rw-r--r--libnm/libnm.ver1
-rw-r--r--src/vpn-manager/nm-vpn-connection.c1
4 files changed, 18 insertions, 23 deletions
diff --git a/libnm-core/nm-vpn-plugin-info.c b/libnm-core/nm-vpn-plugin-info.c
index 6cd1eb8ca3..3a4796b9b5 100644
--- a/libnm-core/nm-vpn-plugin-info.c
+++ b/libnm-core/nm-vpn-plugin-info.c
@@ -48,6 +48,7 @@ typedef struct {
char *filename;
char *name;
char *service;
+ char **aliases;
GKeyFile *keyfile;
/* It is convenient for nm_vpn_plugin_info_lookup_property() to return a const char *,
@@ -426,7 +427,7 @@ nm_vpn_plugin_info_list_add (GSList **list, NMVpnPluginInfo *plugin_info, GError
}
/* the plugin must have unique values for certain properties. E.g. two different
- * plugins cannot share the same D-Bus service name. */
+ * plugins cannot share the same service name. */
if (!_check_no_conflict (plugin_info, iter->data, error))
return FALSE;
}
@@ -525,8 +526,19 @@ nm_vpn_plugin_info_list_find_by_service (GSList *list, const char *service)
if (!service)
g_return_val_if_reached (NULL);
+ /* First, consider the primary service name. */
for (iter = list; iter; iter = iter->next) {
- if (strcmp (nm_vpn_plugin_info_get_service (iter->data), service) == 0)
+ if (strcmp (NM_VPN_PLUGIN_INFO_GET_PRIVATE (iter->data)->service, service) == 0)
+ return iter->data;
+ }
+
+ /* Then look into the aliases. */
+ for (iter = list; iter; iter = iter->next) {
+ char **aliases = (NM_VPN_PLUGIN_INFO_GET_PRIVATE (iter->data))->aliases;
+
+ if (!aliases)
+ continue;
+ if (_nm_utils_strv_find_first (aliases, -1, service) >= 0)
return iter->data;
}
return NULL;
@@ -567,22 +579,6 @@ nm_vpn_plugin_info_get_name (NMVpnPluginInfo *self)
}
/**
- * nm_vpn_plugin_info_get_service:
- * @self: plugin info instance
- *
- * Returns: (transfer none): the service. Cannot be %NULL.
- *
- * Since: 1.2
- */
-const char *
-nm_vpn_plugin_info_get_service (NMVpnPluginInfo *self)
-{
- g_return_val_if_fail (NM_IS_VPN_PLUGIN_INFO (self), NULL);
-
- return NM_VPN_PLUGIN_INFO_GET_PRIVATE (self)->service;
-}
-
-/**
* nm_vpn_plugin_info_get_plugin:
* @self: plugin info instance
*
@@ -760,7 +756,7 @@ nm_vpn_plugin_info_load_editor_plugin (NMVpnPluginInfo *self, GError **error)
priv->editor_plugin_loaded = TRUE;
priv->editor_plugin = nm_vpn_editor_plugin_load_from_file (plugin_filename,
- nm_vpn_plugin_info_get_service (self),
+ priv->service,
getuid (),
NULL,
NULL,
@@ -871,6 +867,8 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
return FALSE;
}
+ priv->aliases = g_key_file_get_string_list (priv->keyfile, NM_VPN_PLUGIN_INFO_KF_GROUP_CONNECTION, "aliases", NULL, NULL);
+
priv->keys = g_hash_table_new_full (_nm_utils_strstrdictkey_hash,
_nm_utils_strstrdictkey_equal,
g_free, g_free);
@@ -951,6 +949,7 @@ finalize (GObject *object)
g_free (priv->name);
g_free (priv->service);
+ g_strfreev (priv->aliases);
g_free (priv->filename);
g_key_file_unref (priv->keyfile);
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 ead6fb708b..667a4fe2d9 100644
--- a/libnm-core/nm-vpn-plugin-info.h
+++ b/libnm-core/nm-vpn-plugin-info.h
@@ -75,8 +75,6 @@ const char *nm_vpn_plugin_info_get_name (NMVpnPluginInfo *self);
NM_AVAILABLE_IN_1_2
const char *nm_vpn_plugin_info_get_filename (NMVpnPluginInfo *self);
NM_AVAILABLE_IN_1_2
-const char *nm_vpn_plugin_info_get_service (NMVpnPluginInfo *self);
-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);
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index 5bf877a811..71ae69f3aa 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -906,7 +906,6 @@ global:
nm_vpn_plugin_info_get_name;
nm_vpn_plugin_info_get_plugin;
nm_vpn_plugin_info_get_program;
- nm_vpn_plugin_info_get_service;
nm_vpn_plugin_info_get_type;
nm_vpn_plugin_info_load_editor_plugin;
nm_vpn_plugin_info_lookup_property;
diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c
index b3ac9d3e05..0c0ac1c740 100644
--- a/src/vpn-manager/nm-vpn-connection.c
+++ b/src/vpn-manager/nm-vpn-connection.c
@@ -2046,7 +2046,6 @@ nm_vpn_connection_activate (NMVpnConnection *self,
g_return_if_fail (s_vpn);
service = nm_setting_vpn_get_service_type (s_vpn);
- g_return_if_fail (!g_strcmp0 (service, nm_vpn_plugin_info_get_service (plugin_info)));
if (nm_vpn_plugin_info_supports_multiple (plugin_info)) {
const char *path;