device: renew dhcp leases on awake for software devices
[NetworkManager.git] / libnm-glib / nm-vpn-plugin.h
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /*
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the
15  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  * Boston, MA 02110-1301 USA.
17  *
18  * Copyright 2007 - 2008 Novell, Inc.
19  * Copyright 2007 - 2013 Red Hat, Inc.
20  */
21
22 #ifndef NM_VPN_PLUGIN_H
23 #define NM_VPN_PLUGIN_H
24
25 #include <glib.h>
26 #include <glib-object.h>
27 #include <dbus/dbus-glib.h>
28 #include <NetworkManagerVPN.h>
29 #include <nm-connection.h>
30
31 G_BEGIN_DECLS
32
33 #define NM_TYPE_VPN_PLUGIN            (nm_vpn_plugin_get_type ())
34 #define NM_VPN_PLUGIN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_PLUGIN, NMVPNPlugin))
35 #define NM_VPN_PLUGIN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_VPN_PLUGIN, NMVPNPluginClass))
36 #define NM_IS_VPN_PLUGIN(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_PLUGIN))
37 #define NM_IS_VPN_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_VPN_PLUGIN))
38 #define NM_VPN_PLUGIN_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_VPN_PLUGIN, NMVPNPluginClass))
39
40 #define NM_VPN_PLUGIN_DBUS_SERVICE_NAME "service-name"
41 #define NM_VPN_PLUGIN_STATE             "state"
42
43 /**
44  * NMVPNPluginError:
45  * @NM_VPN_PLUGIN_ERROR_GENERAL: general failure
46  * @NM_VPN_PLUGIN_ERROR_STARTING_IN_PROGRESS: the plugin is already starting,
47  *  and another connect request was received
48  * @NM_VPN_PLUGIN_ERROR_ALREADY_STARTED: the plugin is already connected, and
49  *  another connect request was received
50  * @NM_VPN_PLUGIN_ERROR_STOPPING_IN_PROGRESS: the plugin is already stopping,
51  *  and another stop request was received
52  * @NM_VPN_PLUGIN_ERROR_ALREADY_STOPPED: the plugin is already stopped, and
53  *  another disconnect request was received
54  * @NM_VPN_PLUGIN_ERROR_WRONG_STATE: the operation could not be performed in
55  *  this state
56  * @NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS: the operation could not be performed as
57  *  the request contained malformed arguments, or arguments of unexpected type.
58  *  Usually means that one of the VPN setting data items or secrets was not of
59  *  the expected type (ie int, string, bool, etc).
60  * @NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED: a child process failed to launch
61  * @NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID: the operation could not be performed
62  *  because the connection was invalid.  Usually means that the connection's
63  *  VPN setting was missing some required data item or secret.
64  * @NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED: the operation could not be
65  *  performed as the plugin does not support interactive operations, such as
66  *  ConnectInteractive() or NewSecrets()
67  *
68  * Returned by the VPN service plugin to indicate errors.
69  **/
70 typedef enum {
71         NM_VPN_PLUGIN_ERROR_GENERAL,                   /*< nick=General >*/
72         NM_VPN_PLUGIN_ERROR_STARTING_IN_PROGRESS,      /*< nick=StartingInProgress >*/
73         NM_VPN_PLUGIN_ERROR_ALREADY_STARTED,           /*< nick=AlreadyStarted >*/
74         NM_VPN_PLUGIN_ERROR_STOPPING_IN_PROGRESS,      /*< nick=StoppingInProgress >*/
75         NM_VPN_PLUGIN_ERROR_ALREADY_STOPPED,           /*< nick=AlreadyStopped >*/
76         NM_VPN_PLUGIN_ERROR_WRONG_STATE,               /*< nick=WrongState >*/
77         NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,             /*< nick=BadArguments >*/
78         NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED,             /*< nick=LaunchFailed >*/
79         NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,        /*< nick=ConnectionInvalid >*/
80         NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED  /*< nick=InteractiveNotSupported >*/
81 } NMVPNPluginError;
82
83 #define NM_VPN_PLUGIN_ERROR      (nm_vpn_plugin_error_quark ())
84
85 typedef struct {
86         GObject parent;
87 } NMVPNPlugin;
88
89 typedef struct {
90         GObjectClass parent;
91
92         /* virtual methods */
93         gboolean (*connect)      (NMVPNPlugin   *plugin,
94                                   NMConnection  *connection,
95                                   GError       **err);
96
97         gboolean (*need_secrets) (NMVPNPlugin *plugin,
98                                   NMConnection *connection,
99                                   char **setting_name,
100                                   GError **error);
101
102         gboolean (*disconnect)   (NMVPNPlugin   *plugin,
103                                   GError       **err);
104
105         /* Signals */
106         void (*state_changed)  (NMVPNPlugin *plugin,
107                                 NMVPNServiceState state);
108
109         void (*ip4_config)     (NMVPNPlugin *plugin,
110                                 GHashTable  *ip4_config);
111
112         void (*login_banner)   (NMVPNPlugin *plugin,
113                                 const char *banner);
114
115         void (*failure)        (NMVPNPlugin *plugin,
116                                 NMVPNPluginFailure reason);
117
118         void (*quit)           (NMVPNPlugin *plugin);
119
120         void (*config)         (NMVPNPlugin *plugin,
121                                 GHashTable  *config);
122
123         void (*ip6_config)     (NMVPNPlugin *plugin,
124                                 GHashTable  *config);
125
126         /* more methods */
127         gboolean (*new_secrets)  (NMVPNPlugin *plugin,
128                                   NMConnection *connection,
129                                   GError **error);
130
131         gboolean (*connect_interactive) (NMVPNPlugin *plugin,
132                                          NMConnection *connection,
133                                          GHashTable *details,
134                                          GError **error);
135
136         /* Padding for future expansion */
137         void (*_reserved1) (void);
138         void (*_reserved2) (void);
139 } NMVPNPluginClass;
140
141 GType  nm_vpn_plugin_get_type       (void);
142 GQuark nm_vpn_plugin_error_quark    (void);
143 GType  nm_vpn_plugin_error_get_type (void);
144
145 DBusGConnection   *nm_vpn_plugin_get_connection (NMVPNPlugin *plugin);
146 NMVPNServiceState  nm_vpn_plugin_get_state      (NMVPNPlugin *plugin);
147 void               nm_vpn_plugin_set_state      (NMVPNPlugin *plugin,
148                                                  NMVPNServiceState state);
149
150 NM_AVAILABLE_IN_0_9_10
151 void               nm_vpn_plugin_secrets_required (NMVPNPlugin *plugin,
152                                                    const char *message,
153                                                    const char **hints);
154
155 void               nm_vpn_plugin_set_login_banner (NMVPNPlugin *plugin,
156                                                    const char *banner);
157
158 void               nm_vpn_plugin_failure        (NMVPNPlugin *plugin,
159                                                  NMVPNPluginFailure reason);
160
161 void               nm_vpn_plugin_set_config     (NMVPNPlugin *plugin,
162                                                  GHashTable *config);
163
164 void               nm_vpn_plugin_set_ip4_config (NMVPNPlugin *plugin,
165                                                  GHashTable *ip4_config);
166
167 void               nm_vpn_plugin_set_ip6_config (NMVPNPlugin *plugin,
168                                                  GHashTable *ip6_config);
169
170 gboolean           nm_vpn_plugin_disconnect     (NMVPNPlugin *plugin,
171                                                  GError **err);
172
173 G_END_DECLS
174
175 #endif /* NM_VPN_PLUGIN_H */