1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2008 Novell, Inc.
4 * Copyright (C) 2008 - 2015 Red Hat, Inc.
5 */
6
7#ifndef __NM_VPN_EDITOR_PLUGIN_H__
8#define __NM_VPN_EDITOR_PLUGIN_H__
9
10#if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION)
11#error "Only <NetworkManager.h> can be included directly."
12#endif
13
14#include <glib.h>
15#include <glib-object.h>
16
17#include "nm-connection.h"
18#include "nm-utils.h"
19
20G_BEGIN_DECLS
21
22typedef struct _NMVpnPluginInfo NMVpnPluginInfo;
23
24typedef struct _NMVpnEditorPlugin NMVpnEditorPlugin;
25typedef struct _NMVpnEditor NMVpnEditor;
26
27/* Plugin's factory function that returns a GObject that implements
28 * NMVpnEditorPlugin.
29 */
30#ifndef __GI_SCANNER__
31typedef NMVpnEditorPlugin *(*NMVpnEditorPluginFactory)(GError **error);
32NMVpnEditorPlugin *nm_vpn_editor_plugin_factory(GError **error);
33#endif
34
35/*****************************************************************************/
36/* Editor plugin interface */
37/*****************************************************************************/
38
39#define NM_TYPE_VPN_EDITOR_PLUGIN (nm_vpn_editor_plugin_get_type())
40#define NM_VPN_EDITOR_PLUGIN(obj) \
41 (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_VPN_EDITOR_PLUGIN, NMVpnEditorPlugin))
42#define NM_IS_VPN_EDITOR_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_VPN_EDITOR_PLUGIN))
43#define NM_VPN_EDITOR_PLUGIN_GET_INTERFACE(obj) \
44 (G_TYPE_INSTANCE_GET_INTERFACE((obj), NM_TYPE_VPN_EDITOR_PLUGIN, NMVpnEditorPluginInterface))
45
46/**
47 * NMVpnEditorPluginCapability:
48 * @NM_VPN_EDITOR_PLUGIN_CAPABILITY_NONE: unknown or no capability
49 * @NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT: the plugin can import new connections
50 * @NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT: the plugin can export connections
51 * @NM_VPN_EDITOR_PLUGIN_CAPABILITY_IPV6: the plugin supports IPv6 addressing
52 *
53 * Flags that indicate certain capabilities of the plugin to editor programs.
54 **/
55typedef enum /*< flags >*/ {
56 NM_VPN_EDITOR_PLUGIN_CAPABILITY_NONE = 0x00,
57 NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT = 0x01,
58 NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT = 0x02,
59 NM_VPN_EDITOR_PLUGIN_CAPABILITY_IPV6 = 0x04
60} NMVpnEditorPluginCapability;
61
62/* Short display name of the VPN plugin */
63#define NM_VPN_EDITOR_PLUGIN_NAME "name"
64
65/* Longer description of the VPN plugin */
66#define NM_VPN_EDITOR_PLUGIN_DESCRIPTION "description"
67
68/* D-Bus service name of the plugin's VPN service */
69#define NM_VPN_EDITOR_PLUGIN_SERVICE "service"
70
71typedef struct _NMVpnEditorPluginVT NMVpnEditorPluginVT;
72
73/**
74 * NMVpnEditorPluginInterface:
75 * @g_iface: the parent interface
76 * @get_editor: returns an #NMVpnEditor, pre-filled with values from @connection
77 * if non-%NULL.
78 * @get_capabilities: returns a bitmask of capabilities.
79 * @import_from_file: Try to import a connection from the specified path. On
80 * success, return a partial #NMConnection object. On error, return %NULL and
81 * set @error with additional information. Note that @error can be %NULL, in
82 * which case no additional error information should be provided.
83 * @export_to_file: Export the given connection to the specified path. Return
84 * %TRUE on success. On error, return %FALSE and set @error with additional
85 * error information. Note that @error can be %NULL, in which case no
86 * additional error information should be provided.
87 * @get_suggested_filename: For a given connection, return a suggested file
88 * name. Returned value will be %NULL or a suggested file name to be freed by
89 * the caller.
90 * @notify_plugin_info_set: A callback to be called when the plugin info is set.
91 * @get_vt: return a virtual function table to implement further functions in
92 * the plugin, without requiring to update libnm. Used by nm_vpn_editor_plugin_get_vt().
93 *
94 * Interface for VPN editor plugins.
95 */
96typedef struct {
97 GTypeInterface g_iface;
98
99 NMVpnEditor *(*get_editor)(NMVpnEditorPlugin *plugin, NMConnection *connection, GError **error);
100
101 NMVpnEditorPluginCapability (*get_capabilities)(NMVpnEditorPlugin *plugin);
102
103 NMConnection *(*import_from_file)(NMVpnEditorPlugin *plugin, const char *path, GError **error);
104
105 gboolean (*export_to_file)(NMVpnEditorPlugin *plugin,
106 const char *path,
107 NMConnection *connection,
108 GError **error);
109
110 char *(*get_suggested_filename)(NMVpnEditorPlugin *plugin, NMConnection *connection);
111
112 void (*notify_plugin_info_set)(NMVpnEditorPlugin *plugin, NMVpnPluginInfo *plugin_info);
113
114 const NMVpnEditorPluginVT *(*get_vt)(NMVpnEditorPlugin *plugin, gsize *out_vt_size);
115} NMVpnEditorPluginInterface;
116
117GType nm_vpn_editor_plugin_get_type(void);
118
119NMVpnEditor *nm_vpn_editor_plugin_get_editor(NMVpnEditorPlugin *plugin,
120 NMConnection *connection,
121 GError **error);
122
123NMVpnEditorPluginCapability nm_vpn_editor_plugin_get_capabilities(NMVpnEditorPlugin *plugin);
124
125NM_AVAILABLE_IN_1_4
126gsize
127nm_vpn_editor_plugin_get_vt(NMVpnEditorPlugin *plugin, NMVpnEditorPluginVT *vt, gsize vt_size);
128
129NMConnection *
130nm_vpn_editor_plugin_import(NMVpnEditorPlugin *plugin, const char *path, GError **error);
131gboolean nm_vpn_editor_plugin_export(NMVpnEditorPlugin *plugin,
132 const char *path,
133 NMConnection *connection,
134 GError **error);
135char *nm_vpn_editor_plugin_get_suggested_filename(NMVpnEditorPlugin *plugin,
136 NMConnection *connection);
137
138NM_AVAILABLE_IN_1_2
139NMVpnEditorPlugin *nm_vpn_editor_plugin_load_from_file(const char *plugin_name,
140 const char *check_service,
141 int check_owner,
142 NMUtilsCheckFilePredicate check_file,
143 gpointer user_data,
144 GError **error);
145
146NM_AVAILABLE_IN_1_4
147NMVpnEditorPlugin *
148nm_vpn_editor_plugin_load(const char *plugin_name, const char *check_service, GError **error);
149
150NM_AVAILABLE_IN_1_4
151NMVpnPluginInfo *nm_vpn_editor_plugin_get_plugin_info(NMVpnEditorPlugin *plugin);
152NM_AVAILABLE_IN_1_4
153void nm_vpn_editor_plugin_set_plugin_info(NMVpnEditorPlugin *plugin, NMVpnPluginInfo *plugin_info);
154
155#include "nm-vpn-plugin-info.h"
156
157G_END_DECLS
158
159#endif /* __NM_VPN_EDITOR_PLUGIN_H__ */
160

source code of include/libnm/nm-vpn-editor-plugin.h