Merge lp:~kvalo/indicator-network/bug-686356 into lp:~indicator-applet-developers/indicator-network/indicator-network
- bug-686356
- Merge into indicator-network
Proposed by
Kalle Valo
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 174 | ||||
Proposed branch: | lp:~kvalo/indicator-network/bug-686356 | ||||
Merge into: | lp:~indicator-applet-developers/indicator-network/indicator-network | ||||
Diff against target: |
1103 lines (+816/-6) 10 files modified
.bzrignore (+1/-0) src/libconnman/Connman-1.0.vapi (+33/-0) src/libconnman/Makefile.am (+3/-1) src/libconnman/connman-ipv6.c (+315/-0) src/libconnman/connman-ipv6.h (+93/-0) src/libconnman/connman-service.c (+243/-5) src/libconnman/connman-service.h (+5/-0) src/libconnman/connman.h (+2/-0) src/libconnman/generate_vapi (+1/-0) src/settings/frontend/widgets/dialogs/edit-connection.vala (+120/-0) |
||||
To merge this branch: | bzr merge lp:~kvalo/indicator-network/bug-686356 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mikkel Kamstrup Erlandsen (community) | Approve | ||
Review via email: mp+53980@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2011-03-09 13:29:43 +0000 | |||
3 | +++ .bzrignore 2011-03-18 12:46:25 +0000 | |||
4 | @@ -121,3 +121,4 @@ | |||
5 | 121 | src/indicator/toggleswitch.c | 121 | src/indicator/toggleswitch.c |
6 | 122 | src/indicator/toggleswitch.h | 122 | src/indicator/toggleswitch.h |
7 | 123 | src/indicator/toggleswitch.stamp | 123 | src/indicator/toggleswitch.stamp |
8 | 124 | src/libconnman/libconnman_la-connman-ipv6.lo | ||
9 | 124 | 125 | ||
10 | === modified file 'src/libconnman/Connman-1.0.vapi' | |||
11 | --- src/libconnman/Connman-1.0.vapi 2011-02-22 13:57:51 +0000 | |||
12 | +++ src/libconnman/Connman-1.0.vapi 2011-03-18 12:46:25 +0000 | |||
13 | @@ -20,6 +20,22 @@ | |||
14 | 20 | public uint method { get; construct; } | 20 | public uint method { get; construct; } |
15 | 21 | public string netmask { get; construct; } | 21 | public string netmask { get; construct; } |
16 | 22 | } | 22 | } |
17 | 23 | [CCode (cheader_filename = "connman-ipv6.h")] | ||
18 | 24 | public class IPv6 : GLib.Object { | ||
19 | 25 | [CCode (has_construct_function = false)] | ||
20 | 26 | public IPv6 (Connman.IPv6Method method, string address, uint8 prefix_length, string gateway) throws GLib.Error; | ||
21 | 27 | public unowned string get_address (); | ||
22 | 28 | public unowned string get_gateway (); | ||
23 | 29 | public Connman.IPv6Method get_method (); | ||
24 | 30 | public unowned string get_method_as_string (); | ||
25 | 31 | public uint8 get_prefix_length (); | ||
26 | 32 | [CCode (has_construct_function = false)] | ||
27 | 33 | public IPv6.with_strings (string method, string address, uint8 prefix_length, string gateway) throws GLib.Error; | ||
28 | 34 | public string address { get; construct; } | ||
29 | 35 | public string gateway { get; construct; } | ||
30 | 36 | public uint method { get; construct; } | ||
31 | 37 | public uint8 prefix_length { get; construct; } | ||
32 | 38 | } | ||
33 | 23 | [CCode (cheader_filename = "connman-manager.h")] | 39 | [CCode (cheader_filename = "connman-manager.h")] |
34 | 24 | public class Manager : GLib.Object { | 40 | public class Manager : GLib.Object { |
35 | 25 | public weak GLib.Object parent; | 41 | public weak GLib.Object parent; |
36 | @@ -63,6 +79,8 @@ | |||
37 | 63 | public bool get_immutable (); | 79 | public bool get_immutable (); |
38 | 64 | public unowned Connman.IPv4 get_ipv4 (); | 80 | public unowned Connman.IPv4 get_ipv4 (); |
39 | 65 | public unowned Connman.IPv4 get_ipv4_configuration (); | 81 | public unowned Connman.IPv4 get_ipv4_configuration (); |
40 | 82 | public unowned Connman.IPv6 get_ipv6 (); | ||
41 | 83 | public unowned Connman.IPv6 get_ipv6_configuration (); | ||
42 | 66 | public bool get_login_required (); | 84 | public bool get_login_required (); |
43 | 67 | public unowned string get_mcc (); | 85 | public unowned string get_mcc (); |
44 | 68 | public unowned string get_mnc (); | 86 | public unowned string get_mnc (); |
45 | @@ -87,6 +105,7 @@ | |||
46 | 87 | public void set_autoconnect (bool autoconnect); | 105 | public void set_autoconnect (bool autoconnect); |
47 | 88 | public void set_domains_configuration ([CCode (array_length = false, array_null_terminated = true)] string[] domains); | 106 | public void set_domains_configuration ([CCode (array_length = false, array_null_terminated = true)] string[] domains); |
48 | 89 | public void set_ipv4_configuration (Connman.IPv4 ipv4); | 107 | public void set_ipv4_configuration (Connman.IPv4 ipv4); |
49 | 108 | public void set_ipv6_configuration (Connman.IPv6 ipv6); | ||
50 | 90 | public void set_nameservers_configuration ([CCode (array_length = false, array_null_terminated = true)] string[] nameservers); | 109 | public void set_nameservers_configuration ([CCode (array_length = false, array_null_terminated = true)] string[] nameservers); |
51 | 91 | public void set_passphrase (string passphrase); | 110 | public void set_passphrase (string passphrase); |
52 | 92 | public static unowned string state2str (Connman.ServiceState state); | 111 | public static unowned string state2str (Connman.ServiceState state); |
53 | @@ -104,6 +123,8 @@ | |||
54 | 104 | public bool immutable { get; } | 123 | public bool immutable { get; } |
55 | 105 | public Connman.IPv4 ipv4 { get; } | 124 | public Connman.IPv4 ipv4 { get; } |
56 | 106 | public Connman.IPv4 ipv4_configuration { get; set; } | 125 | public Connman.IPv4 ipv4_configuration { get; set; } |
57 | 126 | public Connman.IPv6 ipv6 { get; } | ||
58 | 127 | public Connman.IPv6 ipv6_configuration { get; set; } | ||
59 | 107 | public bool login_required { get; } | 128 | public bool login_required { get; } |
60 | 108 | public string mcc { get; } | 129 | public string mcc { get; } |
61 | 109 | public string mnc { get; } | 130 | public string mnc { get; } |
62 | @@ -132,6 +153,18 @@ | |||
63 | 132 | FIXED, | 153 | FIXED, |
64 | 133 | DHCP | 154 | DHCP |
65 | 134 | } | 155 | } |
66 | 156 | [CCode (cprefix = "CONNMAN_IPV6_ERROR_INVALID_", cheader_filename = "connman-ipv6.h")] | ||
67 | 157 | public enum IPv6Error { | ||
68 | 158 | METHOD, | ||
69 | 159 | SETTINGS | ||
70 | 160 | } | ||
71 | 161 | [CCode (cprefix = "CONNMAN_IPV6_METHOD_", cheader_filename = "connman-ipv6.h")] | ||
72 | 162 | public enum IPv6Method { | ||
73 | 163 | OFF, | ||
74 | 164 | MANUAL, | ||
75 | 165 | FIXED, | ||
76 | 166 | AUTO | ||
77 | 167 | } | ||
78 | 135 | [CCode (cprefix = "CONNMAN_SERVICE_MODE_", cheader_filename = "connman-service.h")] | 168 | [CCode (cprefix = "CONNMAN_SERVICE_MODE_", cheader_filename = "connman-service.h")] |
79 | 136 | public enum ServiceMode { | 169 | public enum ServiceMode { |
80 | 137 | MANAGED, | 170 | MANAGED, |
81 | 138 | 171 | ||
82 | === modified file 'src/libconnman/Makefile.am' | |||
83 | --- src/libconnman/Makefile.am 2011-02-02 13:50:19 +0000 | |||
84 | +++ src/libconnman/Makefile.am 2011-03-18 12:46:25 +0000 | |||
85 | @@ -7,7 +7,9 @@ | |||
86 | 7 | connman-service.c \ | 7 | connman-service.c \ |
87 | 8 | connman-service.h \ | 8 | connman-service.h \ |
88 | 9 | connman-ipv4.c \ | 9 | connman-ipv4.c \ |
90 | 10 | connman-ipv4.h | 10 | connman-ipv4.h \ |
91 | 11 | connman-ipv6.c \ | ||
92 | 12 | connman-ipv6.h | ||
93 | 11 | 13 | ||
94 | 12 | libconnman_la_LIBADD = \ | 14 | libconnman_la_LIBADD = \ |
95 | 13 | $(GLIB_LIBS) \ | 15 | $(GLIB_LIBS) \ |
96 | 14 | 16 | ||
97 | === added file 'src/libconnman/connman-ipv6.c' | |||
98 | --- src/libconnman/connman-ipv6.c 1970-01-01 00:00:00 +0000 | |||
99 | +++ src/libconnman/connman-ipv6.c 2011-03-18 12:46:25 +0000 | |||
100 | @@ -0,0 +1,315 @@ | |||
101 | 1 | /* | ||
102 | 2 | * indicator-network - user interface for connman | ||
103 | 3 | * Copyright 2011 Canonical Ltd. | ||
104 | 4 | * | ||
105 | 5 | * Authors: | ||
106 | 6 | * Kalle Valo <kalle.valo@canonical.com> | ||
107 | 7 | * | ||
108 | 8 | * This program is free software: you can redistribute it and/or modify it | ||
109 | 9 | * under the terms of the GNU General Public License version 3, as published | ||
110 | 10 | * by the Free Software Foundation. | ||
111 | 11 | * | ||
112 | 12 | * This program is distributed in the hope that it will be useful, but | ||
113 | 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
114 | 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
115 | 15 | * PURPOSE. See the GNU General Public License for more details. | ||
116 | 16 | * | ||
117 | 17 | * You should have received a copy of the GNU General Public License along | ||
118 | 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
119 | 19 | */ | ||
120 | 20 | |||
121 | 21 | #include "connman-ipv6.h" | ||
122 | 22 | |||
123 | 23 | #include <string.h> | ||
124 | 24 | |||
125 | 25 | G_DEFINE_TYPE(ConnmanIPv6, connman_ipv6, G_TYPE_OBJECT) | ||
126 | 26 | |||
127 | 27 | #define GET_PRIVATE(o) \ | ||
128 | 28 | (G_TYPE_INSTANCE_GET_PRIVATE((o), CONNMAN_TYPE_IPV6, \ | ||
129 | 29 | ConnmanIPv6Private)) | ||
130 | 30 | |||
131 | 31 | typedef struct _ConnmanIPv6Private ConnmanIPv6Private; | ||
132 | 32 | |||
133 | 33 | struct _ConnmanIPv6Private { | ||
134 | 34 | ConnmanIPv6Method method; | ||
135 | 35 | gchar *address; | ||
136 | 36 | guchar prefix_length; | ||
137 | 37 | gchar *gateway; | ||
138 | 38 | }; | ||
139 | 39 | |||
140 | 40 | enum | ||
141 | 41 | { | ||
142 | 42 | /* reserved */ | ||
143 | 43 | PROP_0, | ||
144 | 44 | |||
145 | 45 | PROP_METHOD, | ||
146 | 46 | PROP_ADDRESS, | ||
147 | 47 | PROP_PREFIX_LENGTH, | ||
148 | 48 | PROP_GATEWAY, | ||
149 | 49 | }; | ||
150 | 50 | |||
151 | 51 | struct ipv6_method_entry | ||
152 | 52 | { | ||
153 | 53 | const gchar *str; | ||
154 | 54 | ConnmanIPv6Method method; | ||
155 | 55 | }; | ||
156 | 56 | |||
157 | 57 | static const struct ipv6_method_entry method_map[] = { | ||
158 | 58 | { "off", CONNMAN_IPV6_METHOD_OFF }, | ||
159 | 59 | { "manual", CONNMAN_IPV6_METHOD_MANUAL }, | ||
160 | 60 | { "fixed", CONNMAN_IPV6_METHOD_FIXED }, | ||
161 | 61 | { "auto", CONNMAN_IPV6_METHOD_AUTO }, | ||
162 | 62 | }; | ||
163 | 63 | |||
164 | 64 | static ConnmanIPv6Method str2method(const gchar *state) | ||
165 | 65 | { | ||
166 | 66 | const struct ipv6_method_entry *s; | ||
167 | 67 | guint i; | ||
168 | 68 | |||
169 | 69 | for (i = 0; i < G_N_ELEMENTS(method_map); i++) { | ||
170 | 70 | s = &method_map[i]; | ||
171 | 71 | if (g_strcmp0(s->str, state) == 0) | ||
172 | 72 | return s->method; | ||
173 | 73 | } | ||
174 | 74 | |||
175 | 75 | g_warning("unknown ipv6 method: %s", state); | ||
176 | 76 | |||
177 | 77 | return CONNMAN_IPV6_METHOD_AUTO; | ||
178 | 78 | } | ||
179 | 79 | |||
180 | 80 | static const gchar *method2str(ConnmanIPv6Method method) | ||
181 | 81 | { | ||
182 | 82 | const struct ipv6_method_entry *s; | ||
183 | 83 | guint i; | ||
184 | 84 | |||
185 | 85 | for (i = 0; i < G_N_ELEMENTS(method_map); i++) { | ||
186 | 86 | s = &method_map[i]; | ||
187 | 87 | if (s->method == method) | ||
188 | 88 | return s->str; | ||
189 | 89 | } | ||
190 | 90 | |||
191 | 91 | g_warning("%s(): unknown ipv6 method %d", __func__, method); | ||
192 | 92 | |||
193 | 93 | return "auto"; | ||
194 | 94 | } | ||
195 | 95 | |||
196 | 96 | ConnmanIPv6Method connman_ipv6_get_method(ConnmanIPv6 *self) | ||
197 | 97 | { | ||
198 | 98 | ConnmanIPv6Private *priv = GET_PRIVATE(self); | ||
199 | 99 | |||
200 | 100 | g_return_val_if_fail(CONNMAN_IS_IPV6(self), CONNMAN_IPV6_METHOD_OFF); | ||
201 | 101 | g_return_val_if_fail(priv != NULL, CONNMAN_IPV6_METHOD_OFF); | ||
202 | 102 | |||
203 | 103 | return priv->method; | ||
204 | 104 | } | ||
205 | 105 | |||
206 | 106 | const gchar *connman_ipv6_get_method_as_string(ConnmanIPv6 *self) | ||
207 | 107 | { | ||
208 | 108 | ConnmanIPv6Private *priv = GET_PRIVATE(self); | ||
209 | 109 | |||
210 | 110 | g_return_val_if_fail(CONNMAN_IS_IPV6(self), CONNMAN_IPV6_METHOD_OFF); | ||
211 | 111 | g_return_val_if_fail(priv != NULL, CONNMAN_IPV6_METHOD_OFF); | ||
212 | 112 | |||
213 | 113 | return method2str(priv->method); | ||
214 | 114 | } | ||
215 | 115 | |||
216 | 116 | |||
217 | 117 | const gchar *connman_ipv6_get_address(ConnmanIPv6 *self) | ||
218 | 118 | { | ||
219 | 119 | ConnmanIPv6Private *priv = GET_PRIVATE(self); | ||
220 | 120 | |||
221 | 121 | g_return_val_if_fail(CONNMAN_IS_IPV6(self), NULL); | ||
222 | 122 | g_return_val_if_fail(priv != NULL, NULL); | ||
223 | 123 | |||
224 | 124 | return priv->address; | ||
225 | 125 | } | ||
226 | 126 | |||
227 | 127 | guchar connman_ipv6_get_prefix_length(ConnmanIPv6 *self) | ||
228 | 128 | { | ||
229 | 129 | ConnmanIPv6Private *priv = GET_PRIVATE(self); | ||
230 | 130 | |||
231 | 131 | g_return_val_if_fail(CONNMAN_IS_IPV6(self), 0); | ||
232 | 132 | g_return_val_if_fail(priv != NULL, 0); | ||
233 | 133 | |||
234 | 134 | return priv->prefix_length; | ||
235 | 135 | } | ||
236 | 136 | |||
237 | 137 | const gchar *connman_ipv6_get_gateway(ConnmanIPv6 *self) | ||
238 | 138 | { | ||
239 | 139 | ConnmanIPv6Private *priv = GET_PRIVATE(self); | ||
240 | 140 | |||
241 | 141 | g_return_val_if_fail(CONNMAN_IS_IPV6(self), NULL); | ||
242 | 142 | g_return_val_if_fail(priv != NULL, NULL); | ||
243 | 143 | |||
244 | 144 | return priv->gateway; | ||
245 | 145 | } | ||
246 | 146 | |||
247 | 147 | static void connman_ipv6_set_property(GObject *object, guint property_id, | ||
248 | 148 | const GValue *value, GParamSpec *pspec) | ||
249 | 149 | { | ||
250 | 150 | ConnmanIPv6 *self = CONNMAN_IPV6(object); | ||
251 | 151 | ConnmanIPv6Private *priv = GET_PRIVATE(self); | ||
252 | 152 | |||
253 | 153 | g_return_if_fail(priv != NULL); | ||
254 | 154 | |||
255 | 155 | switch(property_id) { | ||
256 | 156 | case PROP_METHOD: | ||
257 | 157 | priv->method = g_value_get_uint(value); | ||
258 | 158 | break; | ||
259 | 159 | case PROP_ADDRESS: | ||
260 | 160 | g_free(priv->address); | ||
261 | 161 | priv->address = g_value_dup_string(value); | ||
262 | 162 | break; | ||
263 | 163 | case PROP_PREFIX_LENGTH: | ||
264 | 164 | priv->prefix_length = g_value_get_uchar(value); | ||
265 | 165 | break; | ||
266 | 166 | case PROP_GATEWAY: | ||
267 | 167 | g_free(priv->gateway); | ||
268 | 168 | priv->gateway = g_value_dup_string(value); | ||
269 | 169 | break; | ||
270 | 170 | default: | ||
271 | 171 | /* We don't have any other property... */ | ||
272 | 172 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); | ||
273 | 173 | break; | ||
274 | 174 | } | ||
275 | 175 | } | ||
276 | 176 | |||
277 | 177 | static void connman_ipv6_get_property(GObject *object, guint property_id, | ||
278 | 178 | GValue *value, GParamSpec *pspec) | ||
279 | 179 | { | ||
280 | 180 | ConnmanIPv6 *self = CONNMAN_IPV6(object); | ||
281 | 181 | ConnmanIPv6Private *priv = GET_PRIVATE(self); | ||
282 | 182 | |||
283 | 183 | g_return_if_fail(priv != NULL); | ||
284 | 184 | |||
285 | 185 | switch(property_id) { | ||
286 | 186 | case PROP_METHOD: | ||
287 | 187 | g_value_set_uint(value, priv->method); | ||
288 | 188 | break; | ||
289 | 189 | case PROP_ADDRESS: | ||
290 | 190 | g_value_set_string(value, priv->address); | ||
291 | 191 | break; | ||
292 | 192 | case PROP_PREFIX_LENGTH: | ||
293 | 193 | g_value_set_uchar(value, priv->prefix_length); | ||
294 | 194 | break; | ||
295 | 195 | case PROP_GATEWAY: | ||
296 | 196 | g_value_set_string(value, priv->gateway); | ||
297 | 197 | break; | ||
298 | 198 | default: | ||
299 | 199 | /* We don't have any other property... */ | ||
300 | 200 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); | ||
301 | 201 | break; | ||
302 | 202 | } | ||
303 | 203 | } | ||
304 | 204 | |||
305 | 205 | static void connman_ipv6_dispose(GObject *object) | ||
306 | 206 | { | ||
307 | 207 | G_OBJECT_CLASS(connman_ipv6_parent_class)->dispose(object); | ||
308 | 208 | } | ||
309 | 209 | |||
310 | 210 | static void connman_ipv6_finalize(GObject *object) | ||
311 | 211 | { | ||
312 | 212 | ConnmanIPv6 *self = CONNMAN_IPV6(object); | ||
313 | 213 | ConnmanIPv6Private *priv = GET_PRIVATE(self); | ||
314 | 214 | |||
315 | 215 | g_free(priv->address); | ||
316 | 216 | g_free(priv->gateway); | ||
317 | 217 | |||
318 | 218 | G_OBJECT_CLASS(connman_ipv6_parent_class)->finalize(object); | ||
319 | 219 | } | ||
320 | 220 | |||
321 | 221 | static void connman_ipv6_class_init(ConnmanIPv6Class *klass) | ||
322 | 222 | { | ||
323 | 223 | GObjectClass *gobject_class = G_OBJECT_CLASS(klass); | ||
324 | 224 | GParamSpec *pspec; | ||
325 | 225 | |||
326 | 226 | g_type_class_add_private(klass, sizeof(ConnmanIPv6Private)); | ||
327 | 227 | |||
328 | 228 | gobject_class->dispose = connman_ipv6_dispose; | ||
329 | 229 | gobject_class->finalize = connman_ipv6_finalize; | ||
330 | 230 | gobject_class->set_property = connman_ipv6_set_property; | ||
331 | 231 | gobject_class->get_property = connman_ipv6_get_property; | ||
332 | 232 | |||
333 | 233 | pspec = g_param_spec_uint("method", | ||
334 | 234 | "ConnmanIPv6's method property", | ||
335 | 235 | "The ipv6 method", | ||
336 | 236 | 0, G_MAXUINT, | ||
337 | 237 | CONNMAN_IPV6_METHOD_OFF, | ||
338 | 238 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); | ||
339 | 239 | g_object_class_install_property(gobject_class, PROP_METHOD, pspec); | ||
340 | 240 | |||
341 | 241 | pspec = g_param_spec_string("address", | ||
342 | 242 | "ConnmanIPv6's address", | ||
343 | 243 | "IPv6 address", | ||
344 | 244 | NULL, | ||
345 | 245 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); | ||
346 | 246 | g_object_class_install_property(gobject_class, PROP_ADDRESS, pspec); | ||
347 | 247 | |||
348 | 248 | pspec = g_param_spec_uchar("prefix-length", | ||
349 | 249 | "ConnmanIPv6's prefix length", | ||
350 | 250 | "IPv6 prefix length", | ||
351 | 251 | 0, | ||
352 | 252 | 128, | ||
353 | 253 | 0, | ||
354 | 254 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); | ||
355 | 255 | g_object_class_install_property(gobject_class, PROP_PREFIX_LENGTH, pspec); | ||
356 | 256 | |||
357 | 257 | pspec = g_param_spec_string("gateway", | ||
358 | 258 | "ConnmanIPv6's gateway", | ||
359 | 259 | "IPv6 gateway", | ||
360 | 260 | NULL, | ||
361 | 261 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); | ||
362 | 262 | g_object_class_install_property(gobject_class, PROP_GATEWAY, pspec); | ||
363 | 263 | } | ||
364 | 264 | |||
365 | 265 | static void connman_ipv6_init(ConnmanIPv6 *self) | ||
366 | 266 | { | ||
367 | 267 | } | ||
368 | 268 | |||
369 | 269 | ConnmanIPv6 *connman_ipv6_new(ConnmanIPv6Method method, | ||
370 | 270 | const gchar *address, | ||
371 | 271 | guchar prefix_length, | ||
372 | 272 | const gchar *gateway, | ||
373 | 273 | GError **error) | ||
374 | 274 | { | ||
375 | 275 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); | ||
376 | 276 | |||
377 | 277 | return g_object_new(CONNMAN_TYPE_IPV6, | ||
378 | 278 | "method", method, | ||
379 | 279 | "address", address, | ||
380 | 280 | "prefix-length", prefix_length, | ||
381 | 281 | "gateway", gateway, | ||
382 | 282 | NULL); | ||
383 | 283 | } | ||
384 | 284 | |||
385 | 285 | ConnmanIPv6 *connman_ipv6_new_with_strings(const gchar *method, | ||
386 | 286 | const gchar *address, | ||
387 | 287 | guchar prefix_length, | ||
388 | 288 | const gchar *gateway, | ||
389 | 289 | GError **error) | ||
390 | 290 | { | ||
391 | 291 | const struct ipv6_method_entry *s; | ||
392 | 292 | gboolean valid = FALSE; | ||
393 | 293 | guint i; | ||
394 | 294 | |||
395 | 295 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); | ||
396 | 296 | |||
397 | 297 | /* check that method is valid and if not, throw an error */ | ||
398 | 298 | for (i = 0; i < G_N_ELEMENTS(method_map); i++) { | ||
399 | 299 | s = &method_map[i]; | ||
400 | 300 | if (g_strcmp0(s->str, method) == 0) { | ||
401 | 301 | valid = TRUE; | ||
402 | 302 | break; | ||
403 | 303 | } | ||
404 | 304 | } | ||
405 | 305 | |||
406 | 306 | if (valid == FALSE) { | ||
407 | 307 | g_set_error(error, CONNMAN_IPV6_ERROR, | ||
408 | 308 | CONNMAN_IPV6_ERROR_INVALID_METHOD, | ||
409 | 309 | "Invalid ipv6 method: %s", method); | ||
410 | 310 | return NULL; | ||
411 | 311 | } | ||
412 | 312 | |||
413 | 313 | return connman_ipv6_new(str2method(method), address, prefix_length, gateway, | ||
414 | 314 | error); | ||
415 | 315 | } | ||
416 | 0 | 316 | ||
417 | === added file 'src/libconnman/connman-ipv6.h' | |||
418 | --- src/libconnman/connman-ipv6.h 1970-01-01 00:00:00 +0000 | |||
419 | +++ src/libconnman/connman-ipv6.h 2011-03-18 12:46:25 +0000 | |||
420 | @@ -0,0 +1,93 @@ | |||
421 | 1 | /* | ||
422 | 2 | * indicator-network - user interface for connman | ||
423 | 3 | * Copyright 2011 Canonical Ltd. | ||
424 | 4 | * | ||
425 | 5 | * Authors: | ||
426 | 6 | * Kalle Valo <kalle.valo@canonical.com> | ||
427 | 7 | * | ||
428 | 8 | * This program is free software: you can redistribute it and/or modify it | ||
429 | 9 | * under the terms of the GNU General Public License version 3, as published | ||
430 | 10 | * by the Free Software Foundation. | ||
431 | 11 | * | ||
432 | 12 | * This program is distributed in the hope that it will be useful, but | ||
433 | 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
434 | 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
435 | 15 | * PURPOSE. See the GNU General Public License for more details. | ||
436 | 16 | * | ||
437 | 17 | * You should have received a copy of the GNU General Public License along | ||
438 | 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
439 | 19 | */ | ||
440 | 20 | |||
441 | 21 | #ifndef _CONNMAN_IPV6_H_ | ||
442 | 22 | #define _CONNMAN_IPV6_H_ | ||
443 | 23 | |||
444 | 24 | #include <glib-object.h> | ||
445 | 25 | |||
446 | 26 | G_BEGIN_DECLS | ||
447 | 27 | |||
448 | 28 | #define CONNMAN_TYPE_IPV6 connman_ipv6_get_type() | ||
449 | 29 | |||
450 | 30 | #define CONNMAN_IPV6(obj) \ | ||
451 | 31 | (G_TYPE_CHECK_INSTANCE_CAST((obj), CONNMAN_TYPE_IPV6, \ | ||
452 | 32 | ConnmanIPv6)) | ||
453 | 33 | |||
454 | 34 | #define CONNMAN_IPV6_CLASS(klass) \ | ||
455 | 35 | (G_TYPE_CHECK_CLASS_CAST((klass), CONNMAN_TYPE_IPV6, \ | ||
456 | 36 | ConnmanIPv6Class)) | ||
457 | 37 | |||
458 | 38 | #define CONNMAN_IS_IPV6(obj) \ | ||
459 | 39 | (G_TYPE_CHECK_INSTANCE_TYPE((obj), CONNMAN_TYPE_IPV6)) | ||
460 | 40 | |||
461 | 41 | #define CONNMAN_IS_IPV6_CLASS(klass) \ | ||
462 | 42 | (G_TYPE_CHECK_CLASS_TYPE((klass), CONNMAN_TYPE_IPV6)) | ||
463 | 43 | |||
464 | 44 | #define CONNMAN_IPV6_GET_CLASS(obj) \ | ||
465 | 45 | (G_TYPE_INSTANCE_GET_CLASS((obj), CONNMAN_TYPE_IPV6, \ | ||
466 | 46 | ConnmanIPv6Class)) | ||
467 | 47 | |||
468 | 48 | typedef struct { | ||
469 | 49 | GObject parent; | ||
470 | 50 | } ConnmanIPv6; | ||
471 | 51 | |||
472 | 52 | typedef struct { | ||
473 | 53 | GObjectClass parent_class; | ||
474 | 54 | } ConnmanIPv6Class; | ||
475 | 55 | |||
476 | 56 | #define CONNMAN_IPV6_ERROR connman_ipv6_error_quark() | ||
477 | 57 | |||
478 | 58 | static inline GQuark connman_ipv6_error_quark(void) | ||
479 | 59 | { | ||
480 | 60 | return g_quark_from_static_string ("connman-ipv6-error-quark"); | ||
481 | 61 | } | ||
482 | 62 | |||
483 | 63 | typedef enum { | ||
484 | 64 | CONNMAN_IPV6_ERROR_INVALID_METHOD, | ||
485 | 65 | CONNMAN_IPV6_ERROR_INVALID_SETTINGS, | ||
486 | 66 | } ConnmanIPv6Error; | ||
487 | 67 | |||
488 | 68 | typedef enum { | ||
489 | 69 | CONNMAN_IPV6_METHOD_OFF, | ||
490 | 70 | CONNMAN_IPV6_METHOD_MANUAL, | ||
491 | 71 | CONNMAN_IPV6_METHOD_FIXED, | ||
492 | 72 | CONNMAN_IPV6_METHOD_AUTO, | ||
493 | 73 | } ConnmanIPv6Method; | ||
494 | 74 | |||
495 | 75 | GType connman_ipv6_get_type(void); | ||
496 | 76 | |||
497 | 77 | ConnmanIPv6Method connman_ipv6_get_method(ConnmanIPv6 *self); | ||
498 | 78 | const gchar *connman_ipv6_get_method_as_string(ConnmanIPv6 *self); | ||
499 | 79 | const gchar *connman_ipv6_get_address(ConnmanIPv6 *self); | ||
500 | 80 | guchar connman_ipv6_get_prefix_length(ConnmanIPv6 *self); | ||
501 | 81 | const gchar *connman_ipv6_get_gateway(ConnmanIPv6 *self); | ||
502 | 82 | ConnmanIPv6 *connman_ipv6_new(ConnmanIPv6Method method, | ||
503 | 83 | const gchar *address, | ||
504 | 84 | guchar prefix_length, | ||
505 | 85 | const gchar *gateway, | ||
506 | 86 | GError **error); | ||
507 | 87 | ConnmanIPv6 *connman_ipv6_new_with_strings(const gchar *method, | ||
508 | 88 | const gchar *address, | ||
509 | 89 | guchar prefix_length, | ||
510 | 90 | const gchar *gateway, | ||
511 | 91 | GError **error); | ||
512 | 92 | |||
513 | 93 | #endif | ||
514 | 0 | 94 | ||
515 | === modified file 'src/libconnman/connman-service.c' | |||
516 | --- src/libconnman/connman-service.c 2011-02-21 16:24:29 +0000 | |||
517 | +++ src/libconnman/connman-service.c 2011-03-18 12:46:25 +0000 | |||
518 | @@ -65,6 +65,8 @@ | |||
519 | 65 | gchar **domains_configuration; | 65 | gchar **domains_configuration; |
520 | 66 | ConnmanIPv4 *ipv4; | 66 | ConnmanIPv4 *ipv4; |
521 | 67 | ConnmanIPv4 *ipv4_configuration; | 67 | ConnmanIPv4 *ipv4_configuration; |
522 | 68 | ConnmanIPv6 *ipv6; | ||
523 | 69 | ConnmanIPv6 *ipv6_configuration; | ||
524 | 68 | }; | 70 | }; |
525 | 69 | 71 | ||
526 | 70 | enum | 72 | enum |
527 | @@ -99,8 +101,8 @@ | |||
528 | 99 | PROP_DOMAINS_CONFIGURATION, /* rw */ | 101 | PROP_DOMAINS_CONFIGURATION, /* rw */ |
529 | 100 | PROP_IPV4, | 102 | PROP_IPV4, |
530 | 101 | PROP_IPV4_CONFIGURATION, /* rw */ | 103 | PROP_IPV4_CONFIGURATION, /* rw */ |
533 | 102 | /* PROP_IPV6, */ | 104 | PROP_IPV6, |
534 | 103 | /* PROP_IPV6_CONFIGURATION, /\* rw *\/ */ | 105 | PROP_IPV6_CONFIGURATION, /* rw */ |
535 | 104 | /* PROP_PROXY, */ | 106 | /* PROP_PROXY, */ |
536 | 105 | /* PROP_PROXY_CONFIGURATION, /\* rw *\/ */ | 107 | /* PROP_PROXY_CONFIGURATION, /\* rw *\/ */ |
537 | 106 | /* PROP_PROVIDER, */ | 108 | /* PROP_PROVIDER, */ |
538 | @@ -647,6 +649,53 @@ | |||
539 | 647 | g_object_set(self, "ipv4-configuration", ipv4, NULL); | 649 | g_object_set(self, "ipv4-configuration", ipv4, NULL); |
540 | 648 | } | 650 | } |
541 | 649 | 651 | ||
542 | 652 | /** | ||
543 | 653 | * connman_service_get_ipv6: | ||
544 | 654 | * | ||
545 | 655 | * @self: self | ||
546 | 656 | * | ||
547 | 657 | * Returns: (transfer none): Current ipv6 settings. The caller must | ||
548 | 658 | * take a reference. | ||
549 | 659 | */ | ||
550 | 660 | ConnmanIPv6 *connman_service_get_ipv6(ConnmanService *self) | ||
551 | 661 | { | ||
552 | 662 | ConnmanServicePrivate *priv = GET_PRIVATE(self); | ||
553 | 663 | |||
554 | 664 | g_return_val_if_fail(CONNMAN_IS_SERVICE(self), NULL); | ||
555 | 665 | g_return_val_if_fail(priv != NULL, NULL); | ||
556 | 666 | |||
557 | 667 | return priv->ipv6; | ||
558 | 668 | } | ||
559 | 669 | |||
560 | 670 | /** | ||
561 | 671 | * connman_service_get_ipv6_configuration: | ||
562 | 672 | * | ||
563 | 673 | * @self: self | ||
564 | 674 | * | ||
565 | 675 | * Returns: (transfer none): Current configured ipv6 settings. The caller must | ||
566 | 676 | * take a reference. | ||
567 | 677 | */ | ||
568 | 678 | ConnmanIPv6 *connman_service_get_ipv6_configuration(ConnmanService *self) | ||
569 | 679 | { | ||
570 | 680 | ConnmanServicePrivate *priv = GET_PRIVATE(self); | ||
571 | 681 | |||
572 | 682 | g_return_val_if_fail(CONNMAN_IS_SERVICE(self), NULL); | ||
573 | 683 | g_return_val_if_fail(priv != NULL, NULL); | ||
574 | 684 | |||
575 | 685 | return priv->ipv6_configuration; | ||
576 | 686 | } | ||
577 | 687 | |||
578 | 688 | void connman_service_set_ipv6_configuration(ConnmanService *self, | ||
579 | 689 | ConnmanIPv6 *ipv6) | ||
580 | 690 | { | ||
581 | 691 | ConnmanServicePrivate *priv = GET_PRIVATE(self); | ||
582 | 692 | |||
583 | 693 | g_return_if_fail(CONNMAN_IS_SERVICE(self)); | ||
584 | 694 | g_return_if_fail(priv != NULL); | ||
585 | 695 | |||
586 | 696 | g_object_set(self, "ipv6-configuration", ipv6, NULL); | ||
587 | 697 | } | ||
588 | 698 | |||
589 | 650 | const gchar *connman_service_get_path(ConnmanService *self) | 699 | const gchar *connman_service_get_path(ConnmanService *self) |
590 | 651 | { | 700 | { |
591 | 652 | ConnmanServicePrivate *priv = GET_PRIVATE(self); | 701 | ConnmanServicePrivate *priv = GET_PRIVATE(self); |
592 | @@ -1109,6 +1158,11 @@ | |||
593 | 1109 | 1158 | ||
594 | 1110 | out: | 1159 | out: |
595 | 1111 | g_object_notify(G_OBJECT(self), "ipv4"); | 1160 | g_object_notify(G_OBJECT(self), "ipv4"); |
596 | 1161 | |||
597 | 1162 | g_free(method); | ||
598 | 1163 | g_free(address); | ||
599 | 1164 | g_free(netmask); | ||
600 | 1165 | g_free(gateway); | ||
601 | 1112 | } | 1166 | } |
602 | 1113 | 1167 | ||
603 | 1114 | static void ipv4_configuration_updated(ConnmanService *self, GVariant *variant) | 1168 | static void ipv4_configuration_updated(ConnmanService *self, GVariant *variant) |
604 | @@ -1120,9 +1174,9 @@ | |||
605 | 1120 | GVariantIter iter; | 1174 | GVariantIter iter; |
606 | 1121 | GVariant *value; | 1175 | GVariant *value; |
607 | 1122 | 1176 | ||
611 | 1123 | if (priv->ipv4 != NULL) { | 1177 | if (priv->ipv4_configuration != NULL) { |
612 | 1124 | g_object_unref(priv->ipv4); | 1178 | g_object_unref(priv->ipv4_configuration); |
613 | 1125 | priv->ipv4 = NULL; | 1179 | priv->ipv4_configuration = NULL; |
614 | 1126 | } | 1180 | } |
615 | 1127 | 1181 | ||
616 | 1128 | g_variant_iter_init(&iter, variant); | 1182 | g_variant_iter_init(&iter, variant); |
617 | @@ -1162,6 +1216,121 @@ | |||
618 | 1162 | 1216 | ||
619 | 1163 | out: | 1217 | out: |
620 | 1164 | g_object_notify(G_OBJECT(self), "ipv4-configuration"); | 1218 | g_object_notify(G_OBJECT(self), "ipv4-configuration"); |
621 | 1219 | |||
622 | 1220 | g_free(method); | ||
623 | 1221 | g_free(address); | ||
624 | 1222 | g_free(netmask); | ||
625 | 1223 | g_free(gateway); | ||
626 | 1224 | } | ||
627 | 1225 | |||
628 | 1226 | static void ipv6_updated(ConnmanService *self, GVariant *variant) | ||
629 | 1227 | { | ||
630 | 1228 | ConnmanServicePrivate *priv = GET_PRIVATE(self); | ||
631 | 1229 | gchar *method = NULL, *address = NULL, *gateway = NULL, *key; | ||
632 | 1230 | guchar prefix_len = 0; | ||
633 | 1231 | GError *error = NULL; | ||
634 | 1232 | GVariantIter iter; | ||
635 | 1233 | GVariant *value; | ||
636 | 1234 | |||
637 | 1235 | if (priv->ipv6 != NULL) { | ||
638 | 1236 | g_object_unref(priv->ipv6); | ||
639 | 1237 | priv->ipv6 = NULL; | ||
640 | 1238 | } | ||
641 | 1239 | |||
642 | 1240 | g_variant_iter_init(&iter, variant); | ||
643 | 1241 | |||
644 | 1242 | while (g_variant_iter_next(&iter, "{sv}", &key, &value)) { | ||
645 | 1243 | if (g_strcmp0(key, "Method") == 0) | ||
646 | 1244 | method = g_variant_dup_string(value, NULL); | ||
647 | 1245 | else if (g_strcmp0(key, "Address") == 0) | ||
648 | 1246 | address = g_variant_dup_string(value, NULL); | ||
649 | 1247 | else if (g_strcmp0(key, "PrefixLength") == 0) | ||
650 | 1248 | prefix_len = g_variant_get_byte(value); | ||
651 | 1249 | else if (g_strcmp0(key, "Gateway") == 0) | ||
652 | 1250 | gateway = g_variant_dup_string(value, NULL); | ||
653 | 1251 | else | ||
654 | 1252 | g_warning("Unknown ipv6 property: %s", key); | ||
655 | 1253 | |||
656 | 1254 | g_free(key); | ||
657 | 1255 | g_variant_unref(value); | ||
658 | 1256 | } | ||
659 | 1257 | |||
660 | 1258 | if (method == NULL && address == NULL && | ||
661 | 1259 | prefix_len == 0 && gateway == NULL) | ||
662 | 1260 | /* some cases, like with bluetooth, ipv6 dict is just empty */ | ||
663 | 1261 | goto out; | ||
664 | 1262 | |||
665 | 1263 | priv->ipv6 = connman_ipv6_new_with_strings(method, address, prefix_len, | ||
666 | 1264 | gateway, &error); | ||
667 | 1265 | if (error != NULL) { | ||
668 | 1266 | g_warning("Received invalid ipv6 settings: %s", error->message); | ||
669 | 1267 | g_error_free(error); | ||
670 | 1268 | return; | ||
671 | 1269 | } | ||
672 | 1270 | |||
673 | 1271 | out: | ||
674 | 1272 | g_object_notify(G_OBJECT(self), "ipv6"); | ||
675 | 1273 | |||
676 | 1274 | g_free(method); | ||
677 | 1275 | g_free(address); | ||
678 | 1276 | g_free(gateway); | ||
679 | 1277 | } | ||
680 | 1278 | |||
681 | 1279 | static void ipv6_configuration_updated(ConnmanService *self, GVariant *variant) | ||
682 | 1280 | { | ||
683 | 1281 | ConnmanServicePrivate *priv = GET_PRIVATE(self); | ||
684 | 1282 | gchar *method = NULL, *address = NULL, *gateway = NULL, *key; | ||
685 | 1283 | guchar prefix_len = 0; | ||
686 | 1284 | GError *error = NULL; | ||
687 | 1285 | GVariantIter iter; | ||
688 | 1286 | GVariant *value; | ||
689 | 1287 | |||
690 | 1288 | if (priv->ipv6_configuration != NULL) { | ||
691 | 1289 | g_object_unref(priv->ipv6_configuration); | ||
692 | 1290 | priv->ipv6_configuration = NULL; | ||
693 | 1291 | } | ||
694 | 1292 | |||
695 | 1293 | g_variant_iter_init(&iter, variant); | ||
696 | 1294 | |||
697 | 1295 | while (g_variant_iter_next(&iter, "{sv}", &key, &value)) { | ||
698 | 1296 | if (g_strcmp0(key, "Method") == 0) | ||
699 | 1297 | method = g_variant_dup_string(value, NULL); | ||
700 | 1298 | else if (g_strcmp0(key, "Address") == 0) | ||
701 | 1299 | address = g_variant_dup_string(value, NULL); | ||
702 | 1300 | else if (g_strcmp0(key, "PrefixLength") == 0) | ||
703 | 1301 | prefix_len = g_variant_get_byte(value); | ||
704 | 1302 | else if (g_strcmp0(key, "Gateway") == 0) | ||
705 | 1303 | gateway = g_variant_dup_string(value, NULL); | ||
706 | 1304 | else | ||
707 | 1305 | g_warning("Unknown ipv6 property: %s", key); | ||
708 | 1306 | |||
709 | 1307 | g_free(key); | ||
710 | 1308 | g_variant_unref(value); | ||
711 | 1309 | } | ||
712 | 1310 | |||
713 | 1311 | if (method == NULL && address == NULL && | ||
714 | 1312 | prefix_len == 0 && gateway == NULL) | ||
715 | 1313 | /* some cases, like with bluetooth, ipv6 dict is just empty */ | ||
716 | 1314 | goto out; | ||
717 | 1315 | |||
718 | 1316 | priv->ipv6_configuration = connman_ipv6_new_with_strings(method, | ||
719 | 1317 | address, | ||
720 | 1318 | prefix_len, | ||
721 | 1319 | gateway, | ||
722 | 1320 | &error); | ||
723 | 1321 | if (error != NULL) { | ||
724 | 1322 | g_warning("Received invalid ipv6 configuration settings: %s", | ||
725 | 1323 | error->message); | ||
726 | 1324 | g_error_free(error); | ||
727 | 1325 | return; | ||
728 | 1326 | } | ||
729 | 1327 | |||
730 | 1328 | out: | ||
731 | 1329 | g_object_notify(G_OBJECT(self), "ipv6-configuration"); | ||
732 | 1330 | |||
733 | 1331 | g_free(method); | ||
734 | 1332 | g_free(address); | ||
735 | 1333 | g_free(gateway); | ||
736 | 1165 | } | 1334 | } |
737 | 1166 | 1335 | ||
738 | 1167 | struct property_map | 1336 | struct property_map |
739 | @@ -1195,6 +1364,8 @@ | |||
740 | 1195 | { CONNMAN_PROPERTY_DOMAINS_CONFIGURATION, domains_configuration_updated }, | 1364 | { CONNMAN_PROPERTY_DOMAINS_CONFIGURATION, domains_configuration_updated }, |
741 | 1196 | { CONNMAN_PROPERTY_IPV4, ipv4_updated }, | 1365 | { CONNMAN_PROPERTY_IPV4, ipv4_updated }, |
742 | 1197 | { CONNMAN_PROPERTY_IPV4_CONFIGURATION, ipv4_configuration_updated }, | 1366 | { CONNMAN_PROPERTY_IPV4_CONFIGURATION, ipv4_configuration_updated }, |
743 | 1367 | { CONNMAN_PROPERTY_IPV6, ipv6_updated }, | ||
744 | 1368 | { CONNMAN_PROPERTY_IPV6_CONFIGURATION, ipv6_configuration_updated }, | ||
745 | 1198 | }; | 1369 | }; |
746 | 1199 | 1370 | ||
747 | 1200 | static void property_updated(ConnmanService *self, const gchar *property, | 1371 | static void property_updated(ConnmanService *self, const gchar *property, |
748 | @@ -1505,6 +1676,37 @@ | |||
749 | 1505 | set_service_property(self, "IPv4.Configuration", value); | 1676 | set_service_property(self, "IPv4.Configuration", value); |
750 | 1506 | } | 1677 | } |
751 | 1507 | 1678 | ||
752 | 1679 | static void update_ipv6_configuration(ConnmanService *self) | ||
753 | 1680 | { | ||
754 | 1681 | ConnmanServicePrivate *priv = GET_PRIVATE(self); | ||
755 | 1682 | GVariantBuilder builder; | ||
756 | 1683 | gchar prefix_length[10]; | ||
757 | 1684 | ConnmanIPv6 *ipv6; | ||
758 | 1685 | GVariant *value; | ||
759 | 1686 | |||
760 | 1687 | if (priv->ipv6_configuration == NULL) | ||
761 | 1688 | return; | ||
762 | 1689 | |||
763 | 1690 | ipv6 = priv->ipv6_configuration; | ||
764 | 1691 | |||
765 | 1692 | g_variant_builder_init(&builder, G_VARIANT_TYPE("a{ss}")); | ||
766 | 1693 | |||
767 | 1694 | g_variant_builder_add(&builder, "{ss}", "Method", | ||
768 | 1695 | connman_ipv6_get_method_as_string(ipv6)); | ||
769 | 1696 | g_variant_builder_add(&builder, "{ss}", "Address", | ||
770 | 1697 | connman_ipv6_get_address(ipv6)); | ||
771 | 1698 | |||
772 | 1699 | g_snprintf(prefix_length, sizeof(prefix_length), "%d", | ||
773 | 1700 | connman_ipv6_get_prefix_length(ipv6)); | ||
774 | 1701 | g_variant_builder_add(&builder, "{ss}", "PrefixLength", prefix_length); | ||
775 | 1702 | g_variant_builder_add(&builder, "{ss}", "Gateway", | ||
776 | 1703 | connman_ipv6_get_gateway(ipv6)); | ||
777 | 1704 | |||
778 | 1705 | value = g_variant_new("a{ss}", &builder); | ||
779 | 1706 | |||
780 | 1707 | set_service_property(self, "IPv6.Configuration", value); | ||
781 | 1708 | } | ||
782 | 1709 | |||
783 | 1508 | static void connman_service_set_property(GObject *object, | 1710 | static void connman_service_set_property(GObject *object, |
784 | 1509 | guint property_id, | 1711 | guint property_id, |
785 | 1510 | const GValue *value, | 1712 | const GValue *value, |
786 | @@ -1611,6 +1813,17 @@ | |||
787 | 1611 | priv->ipv4_configuration = g_value_dup_object(value); | 1813 | priv->ipv4_configuration = g_value_dup_object(value); |
788 | 1612 | update_ipv4_configuration(self); | 1814 | update_ipv4_configuration(self); |
789 | 1613 | break; | 1815 | break; |
790 | 1816 | case PROP_IPV6: | ||
791 | 1817 | if (priv->ipv6 != NULL) | ||
792 | 1818 | g_object_unref(priv->ipv6); | ||
793 | 1819 | priv->ipv6 = g_value_dup_object(value); | ||
794 | 1820 | break; | ||
795 | 1821 | case PROP_IPV6_CONFIGURATION: | ||
796 | 1822 | if (priv->ipv6_configuration != NULL) | ||
797 | 1823 | g_object_unref(priv->ipv6_configuration); | ||
798 | 1824 | priv->ipv6_configuration = g_value_dup_object(value); | ||
799 | 1825 | update_ipv6_configuration(self); | ||
800 | 1826 | break; | ||
801 | 1614 | default: | 1827 | default: |
802 | 1615 | /* We don't have any other property... */ | 1828 | /* We don't have any other property... */ |
803 | 1616 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); | 1829 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); |
804 | @@ -1727,6 +1940,16 @@ | |||
805 | 1727 | g_object_unref(priv->ipv4_configuration); | 1940 | g_object_unref(priv->ipv4_configuration); |
806 | 1728 | priv->ipv4_configuration = NULL; | 1941 | priv->ipv4_configuration = NULL; |
807 | 1729 | } | 1942 | } |
808 | 1943 | |||
809 | 1944 | if (priv->ipv6 != NULL) { | ||
810 | 1945 | g_object_unref(priv->ipv6); | ||
811 | 1946 | priv->ipv6 = NULL; | ||
812 | 1947 | } | ||
813 | 1948 | |||
814 | 1949 | if (priv->ipv6_configuration != NULL) { | ||
815 | 1950 | g_object_unref(priv->ipv6_configuration); | ||
816 | 1951 | priv->ipv6_configuration = NULL; | ||
817 | 1952 | } | ||
818 | 1730 | } | 1953 | } |
819 | 1731 | 1954 | ||
820 | 1732 | static void connman_service_finalize(GObject *object) | 1955 | static void connman_service_finalize(GObject *object) |
821 | @@ -1956,6 +2179,21 @@ | |||
822 | 1956 | G_PARAM_READWRITE); | 2179 | G_PARAM_READWRITE); |
823 | 1957 | g_object_class_install_property(gobject_class, PROP_IPV4_CONFIGURATION, | 2180 | g_object_class_install_property(gobject_class, PROP_IPV4_CONFIGURATION, |
824 | 1958 | pspec); | 2181 | pspec); |
825 | 2182 | |||
826 | 2183 | pspec = g_param_spec_object("ipv6", | ||
827 | 2184 | "ConnmanService's ipv6 property", | ||
828 | 2185 | "ConnmanIPv6 object", | ||
829 | 2186 | CONNMAN_TYPE_IPV6, | ||
830 | 2187 | G_PARAM_READABLE); | ||
831 | 2188 | g_object_class_install_property(gobject_class, PROP_IPV6, pspec); | ||
832 | 2189 | |||
833 | 2190 | pspec = g_param_spec_object("ipv6-configuration", | ||
834 | 2191 | "ConnmanService's ipv6-configuration property", | ||
835 | 2192 | "ConnmanIPv6 object", | ||
836 | 2193 | CONNMAN_TYPE_IPV6, | ||
837 | 2194 | G_PARAM_READWRITE); | ||
838 | 2195 | g_object_class_install_property(gobject_class, PROP_IPV6_CONFIGURATION, | ||
839 | 2196 | pspec); | ||
840 | 1959 | } | 2197 | } |
841 | 1960 | 2198 | ||
842 | 1961 | static void connman_service_init(ConnmanService *self) | 2199 | static void connman_service_init(ConnmanService *self) |
843 | 1962 | 2200 | ||
844 | === modified file 'src/libconnman/connman-service.h' | |||
845 | --- src/libconnman/connman-service.h 2011-02-21 16:24:29 +0000 | |||
846 | +++ src/libconnman/connman-service.h 2011-03-18 12:46:25 +0000 | |||
847 | @@ -22,6 +22,7 @@ | |||
848 | 22 | #define _CONNMAN_SERVICE_H_ | 22 | #define _CONNMAN_SERVICE_H_ |
849 | 23 | 23 | ||
850 | 24 | #include "connman-ipv4.h" | 24 | #include "connman-ipv4.h" |
851 | 25 | #include "connman-ipv6.h" | ||
852 | 25 | 26 | ||
853 | 26 | #include <glib-object.h> | 27 | #include <glib-object.h> |
854 | 27 | #include <gio/gio.h> | 28 | #include <gio/gio.h> |
855 | @@ -129,6 +130,10 @@ | |||
856 | 129 | ConnmanIPv4 *connman_service_get_ipv4_configuration(ConnmanService *self); | 130 | ConnmanIPv4 *connman_service_get_ipv4_configuration(ConnmanService *self); |
857 | 130 | void connman_service_set_ipv4_configuration(ConnmanService *self, | 131 | void connman_service_set_ipv4_configuration(ConnmanService *self, |
858 | 131 | ConnmanIPv4 *ipv4); | 132 | ConnmanIPv4 *ipv4); |
859 | 133 | ConnmanIPv6 *connman_service_get_ipv6(ConnmanService *self); | ||
860 | 134 | ConnmanIPv6 *connman_service_get_ipv6_configuration(ConnmanService *self); | ||
861 | 135 | void connman_service_set_ipv6_configuration(ConnmanService *self, | ||
862 | 136 | ConnmanIPv6 *ipv6); | ||
863 | 132 | 137 | ||
864 | 133 | /* methods */ | 138 | /* methods */ |
865 | 134 | void connman_service_connect(ConnmanService *self, | 139 | void connman_service_connect(ConnmanService *self, |
866 | 135 | 140 | ||
867 | === modified file 'src/libconnman/connman.h' | |||
868 | --- src/libconnman/connman.h 2011-02-22 13:57:51 +0000 | |||
869 | +++ src/libconnman/connman.h 2011-03-18 12:46:25 +0000 | |||
870 | @@ -74,6 +74,8 @@ | |||
871 | 74 | #define CONNMAN_PROPERTY_DOMAINS_CONFIGURATION "Domains.Configuration" | 74 | #define CONNMAN_PROPERTY_DOMAINS_CONFIGURATION "Domains.Configuration" |
872 | 75 | #define CONNMAN_PROPERTY_IPV4 "IPv4" | 75 | #define CONNMAN_PROPERTY_IPV4 "IPv4" |
873 | 76 | #define CONNMAN_PROPERTY_IPV4_CONFIGURATION "IPv4.Configuration" | 76 | #define CONNMAN_PROPERTY_IPV4_CONFIGURATION "IPv4.Configuration" |
874 | 77 | #define CONNMAN_PROPERTY_IPV6 "IPv6" | ||
875 | 78 | #define CONNMAN_PROPERTY_IPV6_CONFIGURATION "IPv6.Configuration" | ||
876 | 77 | #define CONNMAN_PROPERTY_TECHNOLOGIES "Technologies" | 79 | #define CONNMAN_PROPERTY_TECHNOLOGIES "Technologies" |
877 | 78 | #define CONNMAN_PROPERTY_OFFLINE_MODE "OfflineMode" | 80 | #define CONNMAN_PROPERTY_OFFLINE_MODE "OfflineMode" |
878 | 79 | 81 | ||
879 | 80 | 82 | ||
880 | === modified file 'src/libconnman/generate_vapi' | |||
881 | --- src/libconnman/generate_vapi 2011-02-02 13:50:19 +0000 | |||
882 | +++ src/libconnman/generate_vapi 2011-03-18 12:46:25 +0000 | |||
883 | @@ -18,6 +18,7 @@ | |||
884 | 18 | connman.h connman-manager.c connman-manager.h \ | 18 | connman.h connman-manager.c connman-manager.h \ |
885 | 19 | connman-service.c connman-service.h \ | 19 | connman-service.c connman-service.h \ |
886 | 20 | connman-ipv4.c connman-ipv4.h \ | 20 | connman-ipv4.c connman-ipv4.h \ |
887 | 21 | connman-ipv6.c connman-ipv6.h \ | ||
888 | 21 | libconnman.la | 22 | libconnman.la |
889 | 22 | 23 | ||
890 | 23 | vapigen \ | 24 | vapigen \ |
891 | 24 | 25 | ||
892 | === modified file 'src/settings/frontend/widgets/dialogs/edit-connection.vala' | |||
893 | --- src/settings/frontend/widgets/dialogs/edit-connection.vala 2011-03-17 13:28:03 +0000 | |||
894 | +++ src/settings/frontend/widgets/dialogs/edit-connection.vala 2011-03-18 12:46:25 +0000 | |||
895 | @@ -55,6 +55,15 @@ | |||
896 | 55 | private Gtk.TreeIter ipv4_manual_iter; | 55 | private Gtk.TreeIter ipv4_manual_iter; |
897 | 56 | private Gtk.TreeIter ipv4_dhcp_iter; | 56 | private Gtk.TreeIter ipv4_dhcp_iter; |
898 | 57 | 57 | ||
899 | 58 | /* ipv6 */ | ||
900 | 59 | private Gtk.ComboBox combobox_ipv6_method; | ||
901 | 60 | private Gtk.Entry entry_ipv6_address; | ||
902 | 61 | private Gtk.Entry entry_ipv6_prefix_length; | ||
903 | 62 | private Gtk.Entry entry_ipv6_gateway; | ||
904 | 63 | private Gtk.TreeIter ipv6_off_iter; | ||
905 | 64 | private Gtk.TreeIter ipv6_manual_iter; | ||
906 | 65 | private Gtk.TreeIter ipv6_auto_iter; | ||
907 | 66 | |||
908 | 58 | private Gtk.Entry entry_nameservers; | 67 | private Gtk.Entry entry_nameservers; |
909 | 59 | private Gtk.Entry entry_domains; | 68 | private Gtk.Entry entry_domains; |
910 | 60 | 69 | ||
911 | @@ -153,6 +162,7 @@ | |||
912 | 153 | }); | 162 | }); |
913 | 154 | } | 163 | } |
914 | 155 | 164 | ||
915 | 165 | /* ipv4 combobox */ | ||
916 | 156 | var store = new Gtk.ListStore(2, typeof(int), typeof(string)); | 166 | var store = new Gtk.ListStore(2, typeof(int), typeof(string)); |
917 | 157 | Gtk.TreeIter iter; | 167 | Gtk.TreeIter iter; |
918 | 158 | 168 | ||
919 | @@ -173,6 +183,27 @@ | |||
920 | 173 | store.append(out iter); | 183 | store.append(out iter); |
921 | 174 | store.set(iter, 0, Connman.IPv4Method.DHCP, 1, "DHCP"); | 184 | store.set(iter, 0, Connman.IPv4Method.DHCP, 1, "DHCP"); |
922 | 175 | this.ipv4_dhcp_iter = iter; | 185 | this.ipv4_dhcp_iter = iter; |
923 | 186 | |||
924 | 187 | /* ipv6 combobox */ | ||
925 | 188 | store = new Gtk.ListStore(2, typeof(int), typeof(string)); | ||
926 | 189 | |||
927 | 190 | this.combobox_ipv6_method.model = store; | ||
928 | 191 | |||
929 | 192 | cell = new Gtk.CellRendererText(); | ||
930 | 193 | this.combobox_ipv6_method.pack_start(cell, false); | ||
931 | 194 | this.combobox_ipv6_method.set_attributes(cell, "text", 1); | ||
932 | 195 | |||
933 | 196 | store.append(out iter); | ||
934 | 197 | store.set(iter, 0, Connman.IPv6Method.OFF, 1, "Off"); | ||
935 | 198 | this.ipv6_off_iter = iter; | ||
936 | 199 | |||
937 | 200 | store.append(out iter); | ||
938 | 201 | store.set(iter, 0, Connman.IPv6Method.MANUAL, 1, "Manual"); | ||
939 | 202 | this.ipv6_manual_iter = iter; | ||
940 | 203 | |||
941 | 204 | store.append(out iter); | ||
942 | 205 | store.set(iter, 0, Connman.IPv6Method.AUTO, 1, "Auto"); | ||
943 | 206 | this.ipv6_auto_iter = iter; | ||
944 | 176 | } | 207 | } |
945 | 177 | 208 | ||
946 | 178 | private void get_widgets() { | 209 | private void get_widgets() { |
947 | @@ -203,6 +234,16 @@ | |||
948 | 203 | this.entry_ipv4_gateway = b.get_object("entry_ipv4_gateway") | 234 | this.entry_ipv4_gateway = b.get_object("entry_ipv4_gateway") |
949 | 204 | as Gtk.Entry; | 235 | as Gtk.Entry; |
950 | 205 | 236 | ||
951 | 237 | /* ipv6 */ | ||
952 | 238 | this.combobox_ipv6_method = b.get_object("combobox_ipv6_method") | ||
953 | 239 | as Gtk.ComboBox; | ||
954 | 240 | this.entry_ipv6_address = b.get_object("entry_ipv6_address") | ||
955 | 241 | as Gtk.Entry; | ||
956 | 242 | this.entry_ipv6_prefix_length = b.get_object("entry_ipv6_prefix_length") | ||
957 | 243 | as Gtk.Entry; | ||
958 | 244 | this.entry_ipv6_gateway = b.get_object("entry_ipv6_gateway") | ||
959 | 245 | as Gtk.Entry; | ||
960 | 246 | |||
961 | 206 | /* dns */ | 247 | /* dns */ |
962 | 207 | this.entry_nameservers = b.get_object("entry_nameservers") as Gtk.Entry; | 248 | this.entry_nameservers = b.get_object("entry_nameservers") as Gtk.Entry; |
963 | 208 | this.entry_domains = b.get_object("entry_domains") as Gtk.Entry; | 249 | this.entry_domains = b.get_object("entry_domains") as Gtk.Entry; |
964 | @@ -214,6 +255,7 @@ | |||
965 | 214 | this.button_save.clicked.connect(this.on_button_save_clicked); | 255 | this.button_save.clicked.connect(this.on_button_save_clicked); |
966 | 215 | this.button_cancel.clicked.connect(this.on_button_cancel_clicked); | 256 | this.button_cancel.clicked.connect(this.on_button_cancel_clicked); |
967 | 216 | this.combobox_ipv4_method.changed.connect(ipv4_method_changed); | 257 | this.combobox_ipv4_method.changed.connect(ipv4_method_changed); |
968 | 258 | this.combobox_ipv6_method.changed.connect(ipv6_method_changed); | ||
969 | 217 | } | 259 | } |
970 | 218 | 260 | ||
971 | 219 | private void ipv4_method_changed(Gtk.ComboBox box) { | 261 | private void ipv4_method_changed(Gtk.ComboBox box) { |
972 | @@ -243,6 +285,33 @@ | |||
973 | 243 | } | 285 | } |
974 | 244 | } | 286 | } |
975 | 245 | 287 | ||
976 | 288 | private void ipv6_method_changed(Gtk.ComboBox box) { | ||
977 | 289 | Gtk.TreeIter iter; | ||
978 | 290 | Gtk.ListStore store; | ||
979 | 291 | Connman.IPv6Method method; | ||
980 | 292 | |||
981 | 293 | if (this.combobox_ipv6_method.get_active_iter(out iter) == false) | ||
982 | 294 | return; | ||
983 | 295 | |||
984 | 296 | store = this.combobox_ipv6_method.model as Gtk.ListStore; | ||
985 | 297 | store.get(iter, 0, out method); | ||
986 | 298 | |||
987 | 299 | switch (method) { | ||
988 | 300 | case Connman.IPv6Method.MANUAL: | ||
989 | 301 | this.entry_ipv6_address.sensitive = true; | ||
990 | 302 | this.entry_ipv6_prefix_length.sensitive = true; | ||
991 | 303 | this.entry_ipv6_gateway.sensitive = true; | ||
992 | 304 | break; | ||
993 | 305 | case Connman.IPv6Method.OFF: | ||
994 | 306 | case Connman.IPv6Method.AUTO: | ||
995 | 307 | default: | ||
996 | 308 | this.entry_ipv6_address.sensitive = false; | ||
997 | 309 | this.entry_ipv6_prefix_length.sensitive = false; | ||
998 | 310 | this.entry_ipv6_gateway.sensitive = false; | ||
999 | 311 | break; | ||
1000 | 312 | } | ||
1001 | 313 | } | ||
1002 | 314 | |||
1003 | 246 | private void update_mode() { | 315 | private void update_mode() { |
1004 | 247 | string mode = ""; | 316 | string mode = ""; |
1005 | 248 | 317 | ||
1006 | @@ -345,6 +414,51 @@ | |||
1007 | 345 | } | 414 | } |
1008 | 346 | } | 415 | } |
1009 | 347 | 416 | ||
1010 | 417 | private void update_ipv6() { | ||
1011 | 418 | var ipv6 = this.connection.get_ipv6_configuration(); | ||
1012 | 419 | Gtk.TreeIter iter; | ||
1013 | 420 | |||
1014 | 421 | switch (ipv6.method) { | ||
1015 | 422 | case Connman.IPv6Method.OFF: | ||
1016 | 423 | iter = this.ipv6_off_iter; | ||
1017 | 424 | break; | ||
1018 | 425 | case Connman.IPv6Method.MANUAL: | ||
1019 | 426 | iter = this.ipv6_manual_iter; | ||
1020 | 427 | this.entry_ipv6_address.text = ipv6.address; | ||
1021 | 428 | this.entry_ipv6_prefix_length.text = ipv6.prefix_length.to_string(); | ||
1022 | 429 | this.entry_ipv6_gateway.text = ipv6.gateway; | ||
1023 | 430 | break; | ||
1024 | 431 | case Connman.IPv6Method.AUTO: | ||
1025 | 432 | default: | ||
1026 | 433 | iter = this.ipv6_auto_iter; | ||
1027 | 434 | break; | ||
1028 | 435 | } | ||
1029 | 436 | |||
1030 | 437 | this.combobox_ipv6_method.set_active_iter(iter); | ||
1031 | 438 | } | ||
1032 | 439 | |||
1033 | 440 | private void save_ipv6() { | ||
1034 | 441 | Gtk.TreeIter iter; | ||
1035 | 442 | Connman.IPv6Method method; | ||
1036 | 443 | Connman.IPv6 ipv6; | ||
1037 | 444 | |||
1038 | 445 | var store = this.combobox_ipv6_method.model as Gtk.ListStore; | ||
1039 | 446 | |||
1040 | 447 | this.combobox_ipv6_method.get_active_iter(out iter); | ||
1041 | 448 | store.get(iter, 0, out method); | ||
1042 | 449 | |||
1043 | 450 | var address = this.entry_ipv6_address.text; | ||
1044 | 451 | uint8 prefix_length = (uint8) uint64.parse(this.entry_ipv6_prefix_length.text); | ||
1045 | 452 | var gateway = this.entry_ipv6_gateway.text; | ||
1046 | 453 | |||
1047 | 454 | try { | ||
1048 | 455 | ipv6 = new Connman.IPv6(method, address, prefix_length, gateway); | ||
1049 | 456 | this.connection.set_ipv6_configuration(ipv6); | ||
1050 | 457 | } catch (GLib.Error e) { | ||
1051 | 458 | stderr.printf("Failed to create ipv6 object: %s", e.message); | ||
1052 | 459 | } | ||
1053 | 460 | } | ||
1054 | 461 | |||
1055 | 348 | private void update_nameservers() { | 462 | private void update_nameservers() { |
1056 | 349 | string s = string.joinv(" ", this.connection.get_nameservers_configuration()); | 463 | string s = string.joinv(" ", this.connection.get_nameservers_configuration()); |
1057 | 350 | this.entry_nameservers.set_text(s); | 464 | this.entry_nameservers.set_text(s); |
1058 | @@ -386,6 +500,7 @@ | |||
1059 | 386 | update_security(); | 500 | update_security(); |
1060 | 387 | update_passphrase(); | 501 | update_passphrase(); |
1061 | 388 | update_ipv4(); | 502 | update_ipv4(); |
1062 | 503 | update_ipv6(); | ||
1063 | 389 | update_nameservers(); | 504 | update_nameservers(); |
1064 | 390 | update_domains(); | 505 | update_domains(); |
1065 | 391 | break; | 506 | break; |
1066 | @@ -393,6 +508,7 @@ | |||
1067 | 393 | update_name(); | 508 | update_name(); |
1068 | 394 | update_autoconnect(); | 509 | update_autoconnect(); |
1069 | 395 | update_ipv4(); | 510 | update_ipv4(); |
1070 | 511 | update_ipv6(); | ||
1071 | 396 | update_nameservers(); | 512 | update_nameservers(); |
1072 | 397 | update_domains(); | 513 | update_domains(); |
1073 | 398 | break; | 514 | break; |
1074 | @@ -400,6 +516,7 @@ | |||
1075 | 400 | update_name(); | 516 | update_name(); |
1076 | 401 | update_autoconnect(); | 517 | update_autoconnect(); |
1077 | 402 | update_ipv4(); | 518 | update_ipv4(); |
1078 | 519 | update_ipv6(); | ||
1079 | 403 | update_nameservers(); | 520 | update_nameservers(); |
1080 | 404 | update_domains(); | 521 | update_domains(); |
1081 | 405 | break; | 522 | break; |
1082 | @@ -412,18 +529,21 @@ | |||
1083 | 412 | save_autoconnect(); | 529 | save_autoconnect(); |
1084 | 413 | save_passphrase(); | 530 | save_passphrase(); |
1085 | 414 | save_ipv4(); | 531 | save_ipv4(); |
1086 | 532 | save_ipv6(); | ||
1087 | 415 | save_nameservers(); | 533 | save_nameservers(); |
1088 | 416 | save_domains(); | 534 | save_domains(); |
1089 | 417 | break; | 535 | break; |
1090 | 418 | case Connman.ServiceType.ETHERNET: | 536 | case Connman.ServiceType.ETHERNET: |
1091 | 419 | save_autoconnect(); | 537 | save_autoconnect(); |
1092 | 420 | save_ipv4(); | 538 | save_ipv4(); |
1093 | 539 | save_ipv6(); | ||
1094 | 421 | save_nameservers(); | 540 | save_nameservers(); |
1095 | 422 | save_domains(); | 541 | save_domains(); |
1096 | 423 | break; | 542 | break; |
1097 | 424 | case Connman.ServiceType.BLUETOOTH: | 543 | case Connman.ServiceType.BLUETOOTH: |
1098 | 425 | save_autoconnect(); | 544 | save_autoconnect(); |
1099 | 426 | save_ipv4(); | 545 | save_ipv4(); |
1100 | 546 | save_ipv6(); | ||
1101 | 427 | save_nameservers(); | 547 | save_nameservers(); |
1102 | 428 | save_domains(); | 548 | save_domains(); |
1103 | 429 | break; | 549 | break; |
Really really tight work Kalle.