2020-12-23 22:21:36 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2014-11-05 11:01:09 -05:00
|
|
|
/*
|
2019-10-01 09:20:35 +02:00
|
|
|
* Copyright (C) 2008 Novell, Inc.
|
|
|
|
|
* Copyright (C) 2008 - 2015 Red Hat, Inc.
|
2014-11-05 11:01:09 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __NM_VPN_EDITOR_PLUGIN_H__
|
|
|
|
|
#define __NM_VPN_EDITOR_PLUGIN_H__
|
|
|
|
|
|
|
|
|
|
#if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION)
|
|
|
|
|
#error "Only <NetworkManager.h> can be included directly."
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
#include <glib-object.h>
|
2015-05-25 13:55:37 +02:00
|
|
|
|
|
|
|
|
#include "nm-connection.h"
|
2015-05-28 22:16:00 +02:00
|
|
|
#include "nm-utils.h"
|
2014-11-05 11:01:09 -05:00
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
2018-03-24 15:18:21 +00:00
|
|
|
typedef struct _NMVpnPluginInfo NMVpnPluginInfo;
|
libnm/vpn: pass NMVpnPluginInfo to the NMVpnEditorPlugin instance
The NMVpnPluginInfo is essentially the .name file, that is, a
configuration file about the plugin itself. Via NMVpnPluginInfo
instance, the NMVpnEditorPlugin can be created.
Usually, one would create a NMVpnPluginInfo (that is, reading the
.name file) and then create a NMVpnEditorPlugin instance from there.
In this case, usually the editor-plugin is owned by the plugin-info
instance (although the API allows for creating the editor-plugin
independently).
Now, pass the NMVpnPluginInfo to the editor-plugin too.
This is useful, because then the editor-plugin can look at the .name
file.
The .name file is not user configuration. Instead it is configuration
about the plugin itself. Although the .name file is part of the plugin
build artefacts, it is useful to allow the plugin to access the .name
file. The reason is, that this can allow the user to easily change a
configuration knob of the plugin without requiring to patch or the
plugin.
2016-06-09 00:50:40 +02:00
|
|
|
|
2014-11-07 12:38:17 -05:00
|
|
|
typedef struct _NMVpnEditorPlugin NMVpnEditorPlugin;
|
|
|
|
|
typedef struct _NMVpnEditor NMVpnEditor;
|
|
|
|
|
|
2014-11-05 11:01:09 -05:00
|
|
|
/* Plugin's factory function that returns a GObject that implements
|
|
|
|
|
* NMVpnEditorPlugin.
|
|
|
|
|
*/
|
|
|
|
|
#ifndef __GI_SCANNER__
|
|
|
|
|
typedef NMVpnEditorPlugin *(*NMVpnEditorPluginFactory)(GError **error);
|
|
|
|
|
NMVpnEditorPlugin *nm_vpn_editor_plugin_factory(GError **error);
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2014-11-05 11:01:09 -05:00
|
|
|
/* Editor plugin interface */
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2014-11-05 11:01:09 -05:00
|
|
|
|
|
|
|
|
#define NM_TYPE_VPN_EDITOR_PLUGIN (nm_vpn_editor_plugin_get_type())
|
|
|
|
|
#define NM_VPN_EDITOR_PLUGIN(obj) \
|
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_VPN_EDITOR_PLUGIN, NMVpnEditorPlugin))
|
|
|
|
|
#define NM_IS_VPN_EDITOR_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_VPN_EDITOR_PLUGIN))
|
|
|
|
|
#define NM_VPN_EDITOR_PLUGIN_GET_INTERFACE(obj) \
|
|
|
|
|
(G_TYPE_INSTANCE_GET_INTERFACE((obj), NM_TYPE_VPN_EDITOR_PLUGIN, NMVpnEditorPluginInterface))
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMVpnEditorPluginCapability:
|
|
|
|
|
* @NM_VPN_EDITOR_PLUGIN_CAPABILITY_NONE: unknown or no capability
|
|
|
|
|
* @NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT: the plugin can import new connections
|
|
|
|
|
* @NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT: the plugin can export connections
|
|
|
|
|
* @NM_VPN_EDITOR_PLUGIN_CAPABILITY_IPV6: the plugin supports IPv6 addressing
|
|
|
|
|
*
|
|
|
|
|
* Flags that indicate certain capabilities of the plugin to editor programs.
|
|
|
|
|
**/
|
|
|
|
|
typedef enum /*< flags >*/ {
|
|
|
|
|
NM_VPN_EDITOR_PLUGIN_CAPABILITY_NONE = 0x00,
|
|
|
|
|
NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT = 0x01,
|
|
|
|
|
NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT = 0x02,
|
|
|
|
|
NM_VPN_EDITOR_PLUGIN_CAPABILITY_IPV6 = 0x04
|
|
|
|
|
} NMVpnEditorPluginCapability;
|
|
|
|
|
|
|
|
|
|
/* Short display name of the VPN plugin */
|
|
|
|
|
#define NM_VPN_EDITOR_PLUGIN_NAME "name"
|
|
|
|
|
|
|
|
|
|
/* Longer description of the VPN plugin */
|
|
|
|
|
#define NM_VPN_EDITOR_PLUGIN_DESCRIPTION "description"
|
|
|
|
|
|
|
|
|
|
/* D-Bus service name of the plugin's VPN service */
|
|
|
|
|
#define NM_VPN_EDITOR_PLUGIN_SERVICE "service"
|
|
|
|
|
|
2016-06-13 11:47:58 +02:00
|
|
|
typedef struct _NMVpnEditorPluginVT NMVpnEditorPluginVT;
|
|
|
|
|
|
2014-11-07 12:38:17 -05:00
|
|
|
/**
|
|
|
|
|
* NMVpnEditorPluginInterface:
|
|
|
|
|
* @g_iface: the parent interface
|
|
|
|
|
* @get_editor: returns an #NMVpnEditor, pre-filled with values from @connection
|
|
|
|
|
* if non-%NULL.
|
|
|
|
|
* @get_capabilities: returns a bitmask of capabilities.
|
|
|
|
|
* @import_from_file: Try to import a connection from the specified path. On
|
|
|
|
|
* success, return a partial #NMConnection object. On error, return %NULL and
|
|
|
|
|
* set @error with additional information. Note that @error can be %NULL, in
|
|
|
|
|
* which case no additional error information should be provided.
|
|
|
|
|
* @export_to_file: Export the given connection to the specified path. Return
|
|
|
|
|
* %TRUE on success. On error, return %FALSE and set @error with additional
|
|
|
|
|
* error information. Note that @error can be %NULL, in which case no
|
|
|
|
|
* additional error information should be provided.
|
|
|
|
|
* @get_suggested_filename: For a given connection, return a suggested file
|
|
|
|
|
* name. Returned value will be %NULL or a suggested file name to be freed by
|
|
|
|
|
* the caller.
|
2016-11-20 16:45:59 +01:00
|
|
|
* @notify_plugin_info_set: A callback to be called when the plugin info is set.
|
2016-06-13 11:47:58 +02:00
|
|
|
* @get_vt: return a virtual function table to implement further functions in
|
|
|
|
|
* the plugin, without requiring to update libnm. Used by nm_vpn_editor_plugin_get_vt().
|
2014-11-07 12:38:17 -05:00
|
|
|
*
|
|
|
|
|
* Interface for VPN editor plugins.
|
|
|
|
|
*/
|
2014-11-05 11:01:09 -05:00
|
|
|
typedef struct {
|
|
|
|
|
GTypeInterface g_iface;
|
|
|
|
|
|
|
|
|
|
NMVpnEditor *(*get_editor)(NMVpnEditorPlugin *plugin, NMConnection *connection, GError **error);
|
|
|
|
|
|
|
|
|
|
NMVpnEditorPluginCapability (*get_capabilities)(NMVpnEditorPlugin *plugin);
|
|
|
|
|
|
|
|
|
|
NMConnection *(*import_from_file)(NMVpnEditorPlugin *plugin, const char *path, GError **error);
|
|
|
|
|
|
|
|
|
|
gboolean (*export_to_file)(NMVpnEditorPlugin *plugin,
|
|
|
|
|
const char * path,
|
|
|
|
|
NMConnection * connection,
|
|
|
|
|
GError ** error);
|
|
|
|
|
|
|
|
|
|
char *(*get_suggested_filename)(NMVpnEditorPlugin *plugin, NMConnection *connection);
|
libnm/vpn: pass NMVpnPluginInfo to the NMVpnEditorPlugin instance
The NMVpnPluginInfo is essentially the .name file, that is, a
configuration file about the plugin itself. Via NMVpnPluginInfo
instance, the NMVpnEditorPlugin can be created.
Usually, one would create a NMVpnPluginInfo (that is, reading the
.name file) and then create a NMVpnEditorPlugin instance from there.
In this case, usually the editor-plugin is owned by the plugin-info
instance (although the API allows for creating the editor-plugin
independently).
Now, pass the NMVpnPluginInfo to the editor-plugin too.
This is useful, because then the editor-plugin can look at the .name
file.
The .name file is not user configuration. Instead it is configuration
about the plugin itself. Although the .name file is part of the plugin
build artefacts, it is useful to allow the plugin to access the .name
file. The reason is, that this can allow the user to easily change a
configuration knob of the plugin without requiring to patch or the
plugin.
2016-06-09 00:50:40 +02:00
|
|
|
|
|
|
|
|
void (*notify_plugin_info_set)(NMVpnEditorPlugin *plugin, NMVpnPluginInfo *plugin_info);
|
2016-06-13 11:47:58 +02:00
|
|
|
|
|
|
|
|
const NMVpnEditorPluginVT *(*get_vt)(NMVpnEditorPlugin *plugin, gsize *out_vt_size);
|
2014-11-05 11:01:09 -05:00
|
|
|
} NMVpnEditorPluginInterface;
|
|
|
|
|
|
|
|
|
|
GType nm_vpn_editor_plugin_get_type(void);
|
|
|
|
|
|
|
|
|
|
NMVpnEditor *nm_vpn_editor_plugin_get_editor(NMVpnEditorPlugin *plugin,
|
|
|
|
|
NMConnection * connection,
|
|
|
|
|
GError ** error);
|
|
|
|
|
|
|
|
|
|
NMVpnEditorPluginCapability nm_vpn_editor_plugin_get_capabilities(NMVpnEditorPlugin *plugin);
|
|
|
|
|
|
2016-06-13 11:47:58 +02:00
|
|
|
NM_AVAILABLE_IN_1_4
|
2020-09-28 16:03:33 +02:00
|
|
|
gsize
|
2016-06-13 11:47:58 +02:00
|
|
|
nm_vpn_editor_plugin_get_vt(NMVpnEditorPlugin *plugin, NMVpnEditorPluginVT *vt, gsize vt_size);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2014-11-05 11:01:09 -05:00
|
|
|
NMConnection *
|
|
|
|
|
nm_vpn_editor_plugin_import(NMVpnEditorPlugin *plugin, const char *path, GError **error);
|
|
|
|
|
gboolean nm_vpn_editor_plugin_export(NMVpnEditorPlugin *plugin,
|
|
|
|
|
const char * path,
|
|
|
|
|
NMConnection * connection,
|
|
|
|
|
GError ** error);
|
|
|
|
|
char * nm_vpn_editor_plugin_get_suggested_filename(NMVpnEditorPlugin *plugin,
|
|
|
|
|
NMConnection * connection);
|
|
|
|
|
|
2015-05-28 22:16:00 +02:00
|
|
|
NM_AVAILABLE_IN_1_2
|
2016-04-19 14:39:33 +02:00
|
|
|
NMVpnEditorPlugin *nm_vpn_editor_plugin_load_from_file(const char * plugin_name,
|
2015-05-28 22:16:00 +02:00
|
|
|
const char * check_service,
|
|
|
|
|
int check_owner,
|
|
|
|
|
NMUtilsCheckFilePredicate check_file,
|
|
|
|
|
gpointer user_data,
|
|
|
|
|
GError ** error);
|
|
|
|
|
|
2016-04-18 18:26:28 +02:00
|
|
|
NM_AVAILABLE_IN_1_4
|
|
|
|
|
NMVpnEditorPlugin *
|
|
|
|
|
nm_vpn_editor_plugin_load(const char *plugin_name, const char *check_service, GError **error);
|
|
|
|
|
|
libnm/vpn: pass NMVpnPluginInfo to the NMVpnEditorPlugin instance
The NMVpnPluginInfo is essentially the .name file, that is, a
configuration file about the plugin itself. Via NMVpnPluginInfo
instance, the NMVpnEditorPlugin can be created.
Usually, one would create a NMVpnPluginInfo (that is, reading the
.name file) and then create a NMVpnEditorPlugin instance from there.
In this case, usually the editor-plugin is owned by the plugin-info
instance (although the API allows for creating the editor-plugin
independently).
Now, pass the NMVpnPluginInfo to the editor-plugin too.
This is useful, because then the editor-plugin can look at the .name
file.
The .name file is not user configuration. Instead it is configuration
about the plugin itself. Although the .name file is part of the plugin
build artefacts, it is useful to allow the plugin to access the .name
file. The reason is, that this can allow the user to easily change a
configuration knob of the plugin without requiring to patch or the
plugin.
2016-06-09 00:50:40 +02:00
|
|
|
NM_AVAILABLE_IN_1_4
|
2018-03-24 15:18:21 +00:00
|
|
|
NMVpnPluginInfo *nm_vpn_editor_plugin_get_plugin_info(NMVpnEditorPlugin *plugin);
|
libnm/vpn: pass NMVpnPluginInfo to the NMVpnEditorPlugin instance
The NMVpnPluginInfo is essentially the .name file, that is, a
configuration file about the plugin itself. Via NMVpnPluginInfo
instance, the NMVpnEditorPlugin can be created.
Usually, one would create a NMVpnPluginInfo (that is, reading the
.name file) and then create a NMVpnEditorPlugin instance from there.
In this case, usually the editor-plugin is owned by the plugin-info
instance (although the API allows for creating the editor-plugin
independently).
Now, pass the NMVpnPluginInfo to the editor-plugin too.
This is useful, because then the editor-plugin can look at the .name
file.
The .name file is not user configuration. Instead it is configuration
about the plugin itself. Although the .name file is part of the plugin
build artefacts, it is useful to allow the plugin to access the .name
file. The reason is, that this can allow the user to easily change a
configuration knob of the plugin without requiring to patch or the
plugin.
2016-06-09 00:50:40 +02:00
|
|
|
NM_AVAILABLE_IN_1_4
|
2018-03-24 15:18:21 +00:00
|
|
|
void nm_vpn_editor_plugin_set_plugin_info(NMVpnEditorPlugin *plugin, NMVpnPluginInfo *plugin_info);
|
libnm/vpn: pass NMVpnPluginInfo to the NMVpnEditorPlugin instance
The NMVpnPluginInfo is essentially the .name file, that is, a
configuration file about the plugin itself. Via NMVpnPluginInfo
instance, the NMVpnEditorPlugin can be created.
Usually, one would create a NMVpnPluginInfo (that is, reading the
.name file) and then create a NMVpnEditorPlugin instance from there.
In this case, usually the editor-plugin is owned by the plugin-info
instance (although the API allows for creating the editor-plugin
independently).
Now, pass the NMVpnPluginInfo to the editor-plugin too.
This is useful, because then the editor-plugin can look at the .name
file.
The .name file is not user configuration. Instead it is configuration
about the plugin itself. Although the .name file is part of the plugin
build artefacts, it is useful to allow the plugin to access the .name
file. The reason is, that this can allow the user to easily change a
configuration knob of the plugin without requiring to patch or the
plugin.
2016-06-09 00:50:40 +02:00
|
|
|
|
|
|
|
|
#include "nm-vpn-plugin-info.h"
|
|
|
|
|
|
2014-11-05 11:01:09 -05:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
2018-02-02 10:55:34 +01:00
|
|
|
#endif /* __NM_VPN_EDITOR_PLUGIN_H__ */
|