device: renew dhcp leases on awake for software devices
[NetworkManager.git] / libnm / nm-vpn-service-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 - 2015 Red Hat, Inc.
20  */
21
22 #ifndef __NM_VPN_SERVICE_PLUGIN_H__
23 #define __NM_VPN_SERVICE_PLUGIN_H__
24
25 #if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
26 #error "Only <NetworkManager.h> can be included directly."
27 #endif
28
29 #include <gio/gio.h>
30 #include <nm-vpn-dbus-interface.h>
31 #include <nm-connection.h>
32
33 G_BEGIN_DECLS
34
35 #define NM_TYPE_VPN_SERVICE_PLUGIN            (nm_vpn_service_plugin_get_type ())
36 #define NM_VPN_SERVICE_PLUGIN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_SERVICE_PLUGIN, NMVpnServicePlugin))
37 #define NM_VPN_SERVICE_PLUGIN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_VPN_SERVICE_PLUGIN, NMVpnServicePluginClass))
38 #define NM_IS_VPN_SERVICE_PLUGIN(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_SERVICE_PLUGIN))
39 #define NM_IS_VPN_SERVICE_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_VPN_SERVICE_PLUGIN))
40 #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 typedef struct {
47         NM_AVAILABLE_IN_1_2
48         GObject parent;
49 } NMVpnServicePlugin NM_AVAILABLE_IN_1_2;
50
51 typedef struct {
52         NM_AVAILABLE_IN_1_2
53         GObjectClass parent;
54
55         /* Signals */
56         NM_AVAILABLE_IN_1_2
57         void (*state_changed)  (NMVpnServicePlugin *plugin,
58                                 NMVpnServiceState state);
59
60         NM_AVAILABLE_IN_1_2
61         void (*ip4_config)     (NMVpnServicePlugin *plugin,
62                                 GVariant  *ip4_config);
63
64         NM_AVAILABLE_IN_1_2
65         void (*login_banner)   (NMVpnServicePlugin *plugin,
66                                 const char *banner);
67
68         NM_AVAILABLE_IN_1_2
69         void (*failure)        (NMVpnServicePlugin *plugin,
70                                 NMVpnPluginFailure reason);
71
72         NM_AVAILABLE_IN_1_2
73         void (*quit)           (NMVpnServicePlugin *plugin);
74
75         NM_AVAILABLE_IN_1_2
76         void (*config)         (NMVpnServicePlugin *plugin,
77                                 GVariant  *config);
78
79         NM_AVAILABLE_IN_1_2
80         void (*ip6_config)     (NMVpnServicePlugin *plugin,
81                                 GVariant  *config);
82
83         /* virtual methods */
84         NM_AVAILABLE_IN_1_2
85         gboolean (*connect)      (NMVpnServicePlugin   *plugin,
86                                   NMConnection  *connection,
87                                   GError       **err);
88
89         NM_AVAILABLE_IN_1_2
90         gboolean (*need_secrets) (NMVpnServicePlugin *plugin,
91                                   NMConnection *connection,
92                                   const char **setting_name,
93                                   GError **error);
94
95         NM_AVAILABLE_IN_1_2
96         gboolean (*disconnect)   (NMVpnServicePlugin   *plugin,
97                                   GError       **err);
98
99         NM_AVAILABLE_IN_1_2
100         gboolean (*new_secrets)  (NMVpnServicePlugin *plugin,
101                                   NMConnection *connection,
102                                   GError **error);
103
104         NM_AVAILABLE_IN_1_2
105         gboolean (*connect_interactive) (NMVpnServicePlugin *plugin,
106                                          NMConnection *connection,
107                                          GVariant *details,
108                                          GError **error);
109
110         /*< private >*/
111         NM_AVAILABLE_IN_1_2
112         gpointer padding[8];
113 } NMVpnServicePluginClass NM_AVAILABLE_IN_1_2;
114
115 NM_AVAILABLE_IN_1_2
116 GType  nm_vpn_service_plugin_get_type       (void);
117
118 NM_AVAILABLE_IN_1_2
119 GDBusConnection   *nm_vpn_service_plugin_get_connection (NMVpnServicePlugin *plugin);
120
121 NM_AVAILABLE_IN_1_2
122 void               nm_vpn_service_plugin_secrets_required (NMVpnServicePlugin *plugin,
123                                                            const char *message,
124                                                            const char **hints);
125
126 NM_AVAILABLE_IN_1_2
127 void               nm_vpn_service_plugin_set_login_banner (NMVpnServicePlugin *plugin,
128                                                            const char *banner);
129
130 NM_AVAILABLE_IN_1_2
131 void               nm_vpn_service_plugin_failure        (NMVpnServicePlugin *plugin,
132                                                          NMVpnPluginFailure reason);
133
134 NM_AVAILABLE_IN_1_2
135 void               nm_vpn_service_plugin_set_config     (NMVpnServicePlugin *plugin,
136                                                          GVariant *config);
137
138 NM_AVAILABLE_IN_1_2
139 void               nm_vpn_service_plugin_set_ip4_config (NMVpnServicePlugin *plugin,
140                                                          GVariant *ip4_config);
141
142 NM_AVAILABLE_IN_1_2
143 void               nm_vpn_service_plugin_set_ip6_config (NMVpnServicePlugin *plugin,
144                                                          GVariant *ip6_config);
145
146 NM_AVAILABLE_IN_1_2
147 gboolean           nm_vpn_service_plugin_disconnect     (NMVpnServicePlugin *plugin,
148                                                          GError **err);
149
150 /* Utility functions */
151
152 NM_AVAILABLE_IN_1_2
153 gboolean nm_vpn_service_plugin_read_vpn_details (int fd,
154                                                  GHashTable **out_data,
155                                                  GHashTable **out_secrets);
156
157 NM_AVAILABLE_IN_1_2
158 gboolean nm_vpn_service_plugin_get_secret_flags (GHashTable *data,
159                                                  const char *secret_name,
160                                                  NMSettingSecretFlags *out_flags);
161
162 G_END_DECLS
163
164 #endif /* __NM_VPN_SERVICE_PLUGIN_H__ */