summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-04-18 18:26:28 +0200
committerThomas Haller <thaller@redhat.com>2016-04-19 13:47:42 +0200
commite00eac298118b2016da4db78f88a74bb8c0eb4a4 (patch)
treeb413b7c3922eef8d1de9acf2aa0a5b098216fbb5
parentca000cffbb9ef20c6dd965283df3f1babf0a7745 (diff)
downloadNetworkManager-e00eac298118b2016da4db78f88a74bb8c0eb4a4.tar.gz
libnm/vpn: add nm_vpn_editor_plugin_load() function
Contrary to nm_vpn_editor_plugin_load_from_file(), this allows to specify a library name without path. In this case, g_module_open() (dlopen()) will search for a library in various system directories.
-rw-r--r--libnm-core/nm-vpn-editor-plugin.c42
-rw-r--r--libnm-core/nm-vpn-editor-plugin.h5
-rw-r--r--libnm/libnm.ver5
3 files changed, 51 insertions, 1 deletions
diff --git a/libnm-core/nm-vpn-editor-plugin.c b/libnm-core/nm-vpn-editor-plugin.c
index 32f6cbcdde..84297a82b7 100644
--- a/libnm-core/nm-vpn-editor-plugin.c
+++ b/libnm-core/nm-vpn-editor-plugin.c
@@ -198,7 +198,7 @@ _nm_vpn_editor_plugin_load (const char *plugin_filename,
/**
* nm_vpn_editor_plugin_load_from_file:
- * @plugin_filename: The path to the share library to load.
+ * @plugin_filename: The path to the shared library to load.
* The path must be an absolute filename to an existing file.
* @check_service: if not-null, check that the loaded plugin advertises
* the given service.
@@ -235,6 +235,46 @@ nm_vpn_editor_plugin_load_from_file (const char *plugin_filename,
error);
}
+/**
+ * nm_vpn_editor_plugin_load:
+ * @plugin_name: The name of the shared library to load.
+ * If it is an absolute path, for further checks will be
+ * performed on the file (aside from being a regular file
+ * and existing).
+ * The @plugin_name can also be a library name only. In this
+ * case, system dependent directories will be searched for a
+ * matching library.
+ * @check_service: if not-null, check that the loaded plugin advertises
+ * the given service.
+ * @error: on failure the error reason.
+ *
+ * Load the shared libary @plugin_filename and create a new
+ * #NMVpnEditorPlugin instace via the #NMVpnEditorPluginFactory
+ * function.
+ *
+ * This is similar to nm_vpn_editor_plugin_load_from_file(), but
+ * also allows searching for a matching library and not perform
+ * any checks on the file. If you have the full path to a plugin
+ * file, nm_vpn_editor_plugin_load_from_file() is preferred.
+ *
+ * Returns: (transfer full): a new plugin instance or %NULL on error.
+ *
+ * Since: 1.4
+ */
+NMVpnEditorPlugin *
+nm_vpn_editor_plugin_load (const char *plugin_name,
+ const char *check_service,
+ GError **error)
+{
+ return _nm_vpn_editor_plugin_load (plugin_name,
+ FALSE,
+ check_service,
+ -1,
+ NULL,
+ NULL,
+ error);
+}
+
/*********************************************************************/
/**
diff --git a/libnm-core/nm-vpn-editor-plugin.h b/libnm-core/nm-vpn-editor-plugin.h
index 16e9533d23..7f70a40c2a 100644
--- a/libnm-core/nm-vpn-editor-plugin.h
+++ b/libnm-core/nm-vpn-editor-plugin.h
@@ -147,6 +147,11 @@ NMVpnEditorPlugin *nm_vpn_editor_plugin_load_from_file (const char *plugin_file
gpointer user_data,
GError **error);
+NM_AVAILABLE_IN_1_4
+NMVpnEditorPlugin *nm_vpn_editor_plugin_load (const char *plugin_name,
+ const char *check_service,
+ GError **error);
+
G_END_DECLS
#endif /* __NM_VPN_EDITOR_PLUGIN_H__ */
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index 7ece1b2fef..7faac666d0 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -1058,3 +1058,8 @@ global:
nm_vpn_service_plugin_set_ip6_config;
nm_vpn_service_plugin_set_login_banner;
} libnm_1_0_0;
+
+libnm_1_4_0 {
+global:
+ nm_vpn_editor_plugin_load;
+} libnm_1_2_0;