nm-vpn-service-plugin.h 6.28 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA.
 *
 * Copyright 2007 - 2008 Novell, Inc.
19
 * Copyright 2007 - 2015 Red Hat, Inc.
20 21
 */

22 23
#ifndef __NM_VPN_SERVICE_PLUGIN_H__
#define __NM_VPN_SERVICE_PLUGIN_H__
24

25 26 27 28
#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
#error "Only <NetworkManager.h> can be included directly."
#endif

29
#include <gio/gio.h>
30 31
#include "nm-vpn-dbus-interface.h"
#include "nm-connection.h"
32 33 34

G_BEGIN_DECLS

35 36 37 38 39 40
#define NM_TYPE_VPN_SERVICE_PLUGIN            (nm_vpn_service_plugin_get_type ())
#define NM_VPN_SERVICE_PLUGIN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_SERVICE_PLUGIN, NMVpnServicePlugin))
#define NM_VPN_SERVICE_PLUGIN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_VPN_SERVICE_PLUGIN, NMVpnServicePluginClass))
#define NM_IS_VPN_SERVICE_PLUGIN(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_SERVICE_PLUGIN))
#define NM_IS_VPN_SERVICE_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_VPN_SERVICE_PLUGIN))
#define NM_VPN_SERVICE_PLUGIN_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_VPN_SERVICE_PLUGIN, NMVpnServicePluginClass))
41

42
#define NM_VPN_SERVICE_PLUGIN_DBUS_SERVICE_NAME "service-name"
43
#define NM_VPN_SERVICE_PLUGIN_DBUS_WATCH_PEER   "watch-peer"
44
#define NM_VPN_SERVICE_PLUGIN_STATE             "state"
45

46 47 48
/**
 * NMVpnServicePlugin:
 */
49
typedef struct {
50
	NM_AVAILABLE_IN_1_2
51
	GObject parent;
52
} NMVpnServicePlugin NM_AVAILABLE_IN_1_2;
53 54

typedef struct {
55
	NM_AVAILABLE_IN_1_2
56 57 58
	GObjectClass parent;

	/* Signals */
59
	NM_AVAILABLE_IN_1_2
60
	void (*state_changed)  (NMVpnServicePlugin *plugin,
61 62
	                        NMVpnServiceState state);

63
	NM_AVAILABLE_IN_1_2
64
	void (*ip4_config)     (NMVpnServicePlugin *plugin,
65 66
	                        GVariant  *ip4_config);

67
	NM_AVAILABLE_IN_1_2
68
	void (*login_banner)   (NMVpnServicePlugin *plugin,
69 70
	                        const char *banner);

71
	NM_AVAILABLE_IN_1_2
72
	void (*failure)        (NMVpnServicePlugin *plugin,
73 74
	                        NMVpnPluginFailure reason);

75
	NM_AVAILABLE_IN_1_2
76
	void (*quit)           (NMVpnServicePlugin *plugin);
77

78
	NM_AVAILABLE_IN_1_2
79
	void (*config)         (NMVpnServicePlugin *plugin,
80 81
	                        GVariant  *config);

82
	NM_AVAILABLE_IN_1_2
83
	void (*ip6_config)     (NMVpnServicePlugin *plugin,
84 85 86
	                        GVariant  *config);

	/* virtual methods */
87
	NM_AVAILABLE_IN_1_2
88
	gboolean (*connect)      (NMVpnServicePlugin   *plugin,
89 90 91
	                          NMConnection  *connection,
	                          GError       **err);

92
	NM_AVAILABLE_IN_1_2
93
	gboolean (*need_secrets) (NMVpnServicePlugin *plugin,
94 95 96 97
	                          NMConnection *connection,
	                          const char **setting_name,
	                          GError **error);

98
	NM_AVAILABLE_IN_1_2
99
	gboolean (*disconnect)   (NMVpnServicePlugin   *plugin,
100 101
	                          GError       **err);

102
	NM_AVAILABLE_IN_1_2
103
	gboolean (*new_secrets)  (NMVpnServicePlugin *plugin,
104 105 106
	                          NMConnection *connection,
	                          GError **error);

107
	NM_AVAILABLE_IN_1_2
108
	gboolean (*connect_interactive) (NMVpnServicePlugin *plugin,
109 110 111 112 113
	                                 NMConnection *connection,
	                                 GVariant *details,
	                                 GError **error);

	/*< private >*/
114
	NM_AVAILABLE_IN_1_2
115
	gpointer padding[8];
116
} NMVpnServicePluginClass NM_AVAILABLE_IN_1_2;
117

118
NM_AVAILABLE_IN_1_2
119
GType  nm_vpn_service_plugin_get_type       (void);
120

121
NM_AVAILABLE_IN_1_2
122
GDBusConnection   *nm_vpn_service_plugin_get_connection (NMVpnServicePlugin *plugin);
123

124
NM_AVAILABLE_IN_1_2
125 126 127
void               nm_vpn_service_plugin_secrets_required (NMVpnServicePlugin *plugin,
                                                           const char *message,
                                                           const char **hints);
128

129
NM_AVAILABLE_IN_1_2
130 131
void               nm_vpn_service_plugin_set_login_banner (NMVpnServicePlugin *plugin,
                                                           const char *banner);
132

133
NM_AVAILABLE_IN_1_2
134 135
void               nm_vpn_service_plugin_failure        (NMVpnServicePlugin *plugin,
                                                         NMVpnPluginFailure reason);
136

137
NM_AVAILABLE_IN_1_2
138 139
void               nm_vpn_service_plugin_set_config     (NMVpnServicePlugin *plugin,
                                                         GVariant *config);
140

141
NM_AVAILABLE_IN_1_2
142 143
void               nm_vpn_service_plugin_set_ip4_config (NMVpnServicePlugin *plugin,
                                                         GVariant *ip4_config);
144

145
NM_AVAILABLE_IN_1_2
146 147
void               nm_vpn_service_plugin_set_ip6_config (NMVpnServicePlugin *plugin,
                                                         GVariant *ip6_config);
148

149
NM_AVAILABLE_IN_1_2
150 151
gboolean           nm_vpn_service_plugin_disconnect     (NMVpnServicePlugin *plugin,
                                                         GError **err);
152

153 154 155
NM_AVAILABLE_IN_1_12
void               nm_vpn_service_plugin_shutdown (NMVpnServicePlugin *plugin);

156 157
/* Utility functions */

158
NM_AVAILABLE_IN_1_2
159 160 161
gboolean nm_vpn_service_plugin_read_vpn_details (int fd,
                                                 GHashTable **out_data,
                                                 GHashTable **out_secrets);
162

163
NM_AVAILABLE_IN_1_2
164 165 166
gboolean nm_vpn_service_plugin_get_secret_flags (GHashTable *data,
                                                 const char *secret_name,
                                                 NMSettingSecretFlags *out_flags);
167 168 169

G_END_DECLS

170
#endif /* __NM_VPN_SERVICE_PLUGIN_H__ */