a7b3d0cd34b198ce219c22251e5c712d05da06ea
[NetworkManager.git] / src / nm-active-connection.h
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* NetworkManager -- Network link manager
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  *
18  * Copyright (C) 2008 - 2012 Red Hat, Inc.
19  */
20
21 #ifndef __NETWORKMANAGER_ACTIVE_CONNECTION_H__
22 #define __NETWORKMANAGER_ACTIVE_CONNECTION_H__
23
24 #include "nm-exported-object.h"
25 #include "nm-connection.h"
26
27 #define NM_TYPE_ACTIVE_CONNECTION            (nm_active_connection_get_type ())
28 #define NM_ACTIVE_CONNECTION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnection))
29 #define NM_ACTIVE_CONNECTION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionClass))
30 #define NM_IS_ACTIVE_CONNECTION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_ACTIVE_CONNECTION))
31 #define NM_IS_ACTIVE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_ACTIVE_CONNECTION))
32 #define NM_ACTIVE_CONNECTION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionClass))
33
34 /* D-Bus Exported Properties */
35 #define NM_ACTIVE_CONNECTION_CONNECTION      "connection"
36 #define NM_ACTIVE_CONNECTION_ID              "id"
37 #define NM_ACTIVE_CONNECTION_UUID            "uuid"
38 #define NM_ACTIVE_CONNECTION_TYPE            "type"
39 #define NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT "specific-object"
40 #define NM_ACTIVE_CONNECTION_DEVICES         "devices"
41 #define NM_ACTIVE_CONNECTION_STATE           "state"
42 #define NM_ACTIVE_CONNECTION_DEFAULT         "default"
43 #define NM_ACTIVE_CONNECTION_IP4_CONFIG      "ip4-config"
44 #define NM_ACTIVE_CONNECTION_DHCP4_CONFIG    "dhcp4-config"
45 #define NM_ACTIVE_CONNECTION_DEFAULT6        "default6"
46 #define NM_ACTIVE_CONNECTION_IP6_CONFIG      "ip6-config"
47 #define NM_ACTIVE_CONNECTION_DHCP6_CONFIG    "dhcp6-config"
48 #define NM_ACTIVE_CONNECTION_VPN             "vpn"
49 #define NM_ACTIVE_CONNECTION_MASTER          "master"
50
51 /* Internal non-exported properties */
52 #define NM_ACTIVE_CONNECTION_INT_SETTINGS_CONNECTION "int-settings-connection"
53 #define NM_ACTIVE_CONNECTION_INT_DEVICE         "int-device"
54 #define NM_ACTIVE_CONNECTION_INT_SUBJECT        "int-subject"
55 #define NM_ACTIVE_CONNECTION_INT_MASTER         "int-master"
56 #define NM_ACTIVE_CONNECTION_INT_MASTER_READY   "int-master-ready"
57
58 /* Internal signals*/
59 #define NM_ACTIVE_CONNECTION_DEVICE_CHANGED          "device-changed"
60 #define NM_ACTIVE_CONNECTION_DEVICE_METERED_CHANGED  "device-metered-changed"
61
62 struct _NMActiveConnection {
63         NMExportedObject parent;
64 };
65
66 typedef struct {
67         NMExportedObjectClass parent;
68
69         /* re-emits device state changes as a convenience for subclasses for
70          * device states >= DISCONNECTED.
71          */
72         void (*device_state_changed) (NMActiveConnection *connection,
73                                       NMDevice *device,
74                                       NMDeviceState new_state,
75                                       NMDeviceState old_state);
76         void (*master_failed)  (NMActiveConnection *connection);
77
78         void (*device_changed) (NMActiveConnection *connection,
79                                 NMDevice *new_device,
80                                 NMDevice *old_device);
81
82         void (*device_metered_changed) (NMActiveConnection *connection,
83                                         NMMetered new_value);
84 } NMActiveConnectionClass;
85
86 guint64 nm_active_connection_version_id_get (NMActiveConnection *self);
87 guint64 nm_active_connection_version_id_bump (NMActiveConnection *self);
88
89 GType         nm_active_connection_get_type (void);
90
91 typedef void (*NMActiveConnectionAuthResultFunc) (NMActiveConnection *self,
92                                                   gboolean success,
93                                                   const char *error_desc,
94                                                   gpointer user_data1,
95                                                   gpointer user_data2);
96
97 void          nm_active_connection_authorize (NMActiveConnection *self,
98                                               NMConnection *initial_connection,
99                                               NMActiveConnectionAuthResultFunc result_func,
100                                               gpointer user_data1,
101                                               gpointer user_data2);
102
103 NMSettingsConnection *nm_active_connection_get_settings_connection (NMActiveConnection *self);
104 NMConnection *nm_active_connection_get_applied_connection (NMActiveConnection *self);
105
106 NMSettingsConnection *_nm_active_connection_get_settings_connection (NMActiveConnection *self);
107
108 void          nm_active_connection_set_settings_connection (NMActiveConnection *self,
109                                                             NMSettingsConnection *connection);
110
111 gboolean      nm_active_connection_has_unmodified_applied_connection (NMActiveConnection *self,
112                                                                       NMSettingCompareFlags compare_flags);
113
114 const char *  nm_active_connection_get_settings_connection_id         (NMActiveConnection *self);
115
116 const char *  nm_active_connection_get_specific_object (NMActiveConnection *self);
117
118 void          nm_active_connection_set_specific_object (NMActiveConnection *self,
119                                                         const char *specific_object);
120
121 void          nm_active_connection_set_default (NMActiveConnection *self,
122                                                 gboolean is_default);
123
124 gboolean      nm_active_connection_get_default (NMActiveConnection *self);
125
126 void          nm_active_connection_set_default6 (NMActiveConnection *self,
127                                                  gboolean is_default6);
128
129 gboolean      nm_active_connection_get_default6 (NMActiveConnection *self);
130
131 NMActiveConnectionState nm_active_connection_get_state (NMActiveConnection *self);
132
133 void          nm_active_connection_set_state (NMActiveConnection *self,
134                                               NMActiveConnectionState state);
135
136 NMDevice *    nm_active_connection_get_device (NMActiveConnection *self);
137
138 gboolean      nm_active_connection_set_device (NMActiveConnection *self, NMDevice *device);
139
140 NMAuthSubject *nm_active_connection_get_subject (NMActiveConnection *self);
141
142 gboolean      nm_active_connection_get_user_requested (NMActiveConnection *self);
143
144 NMActiveConnection *nm_active_connection_get_master (NMActiveConnection *self);
145
146 gboolean      nm_active_connection_get_master_ready (NMActiveConnection *self);
147
148 void          nm_active_connection_set_master (NMActiveConnection *self,
149                                                NMActiveConnection *master);
150
151 void          nm_active_connection_set_assumed (NMActiveConnection *self,
152                                                 gboolean assumed);
153
154 gboolean      nm_active_connection_get_assumed (NMActiveConnection *self);
155
156 void          nm_active_connection_clear_secrets (NMActiveConnection *self);
157
158 #endif /* __NETWORKMANAGER_ACTIVE_CONNECTION_H__ */