diff options
author | Koen Kooi <koen@dominion.thruhere.net> | 2011-06-12 18:24:18 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-06-14 15:28:24 +0100 |
commit | 9017f19857b21472ec52cb102e44b060bc305897 (patch) | |
tree | b54e947d90640730044525e35031265e830a6366 /meta/recipes-connectivity | |
parent | c69bbc06ac11d9fb3fdd98c71fd0157dcd249c0e (diff) | |
download | poky-9017f19857b21472ec52cb102e44b060bc305897.tar.gz |
connman-gnome 0.5: build from git
All the local patches were applied upstream, so let's build straight from git to make that clear
(From OE-Core rev: 28246a275a0d7208f0361735685688803965648e)
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-connectivity')
5 files changed, 4 insertions, 4268 deletions
diff --git a/meta/recipes-connectivity/connman/connman-gnome/applet_menu_popup_fix.patch b/meta/recipes-connectivity/connman/connman-gnome/applet_menu_popup_fix.patch deleted file mode 100644 index d34257ba0f..0000000000 --- a/meta/recipes-connectivity/connman/connman-gnome/applet_menu_popup_fix.patch +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | Even if all services are not available, we still need to let user have | ||
2 | the ability to configure network, for example, online/offline, etc. | ||
3 | Therefore enable the callback menu even when status is unavailable. | ||
4 | |||
5 | Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com> | ||
6 | |||
7 | diff --git a/applet/status.c b/applet/status.c | ||
8 | index 13ec752..d817f22 100644 | ||
9 | --- a/applet/status.c | ||
10 | +++ b/applet/status.c | ||
11 | @@ -231,8 +231,6 @@ void status_unavailable(void) | ||
12 | { | ||
13 | icon_animation_stop(animation); | ||
14 | |||
15 | - available = FALSE; | ||
16 | - | ||
17 | gtk_status_icon_set_from_pixbuf(statusicon, pixbuf_notifier); | ||
18 | gtk_status_icon_set_tooltip(statusicon, | ||
19 | "Connection Manager daemon is not running"); | ||
diff --git a/meta/recipes-connectivity/connman/connman-gnome/connman-gnome.patch b/meta/recipes-connectivity/connman/connman-gnome/connman-gnome.patch deleted file mode 100644 index 2fe8bb80fb..0000000000 --- a/meta/recipes-connectivity/connman/connman-gnome/connman-gnome.patch +++ /dev/null | |||
@@ -1,4162 +0,0 @@ | |||
1 | connman-gnome: Change the code to fit recent connman | ||
2 | |||
3 | The recent connman changes from "device" based to "service" based. | ||
4 | Therefore most of the interaction protocol between connman and | ||
5 | connman-gnome has changed. This commit uses the new dbus interface | ||
6 | to interact with connman. With this change, connman-gnome could | ||
7 | do wired and wireless interface configurations with latest connman. | ||
8 | |||
9 | Besides, some UI is re-designed to be more neat and friendly to | ||
10 | end user. | ||
11 | |||
12 | Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com> | ||
13 | |||
14 | diff --git a/applet/main.c b/applet/main.c | ||
15 | index 2a9b36e..08d394c 100644 | ||
16 | --- a/applet/main.c | ||
17 | +++ b/applet/main.c | ||
18 | @@ -98,279 +98,21 @@ static void settings_callback(GtkWidget *item, gpointer user_data) | ||
19 | g_printerr("Couldn't execute command: %s\n", command); | ||
20 | } | ||
21 | |||
22 | -static void toggled_callback(GtkWidget *button, gpointer user_data) | ||
23 | -{ | ||
24 | - GtkWidget *entry = user_data; | ||
25 | - gboolean mode; | ||
26 | - | ||
27 | - mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); | ||
28 | - | ||
29 | - gtk_entry_set_visibility(GTK_ENTRY(entry), mode); | ||
30 | -} | ||
31 | - | ||
32 | -static void passphrase_dialog(const char *path, const char *name) | ||
33 | -{ | ||
34 | - GtkWidget *dialog; | ||
35 | - GtkWidget *button; | ||
36 | - GtkWidget *image; | ||
37 | - GtkWidget *label; | ||
38 | - GtkWidget *entry; | ||
39 | - GtkWidget *table; | ||
40 | - GtkWidget *vbox; | ||
41 | - | ||
42 | - dialog = gtk_dialog_new(); | ||
43 | - gtk_window_set_title(GTK_WINDOW(dialog), _("Enter passphrase")); | ||
44 | - gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | ||
45 | - gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); | ||
46 | - gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE); | ||
47 | - gtk_window_set_urgency_hint(GTK_WINDOW(dialog), TRUE); | ||
48 | - gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | ||
49 | - | ||
50 | - button = gtk_dialog_add_button(GTK_DIALOG(dialog), | ||
51 | - GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT); | ||
52 | - button = gtk_dialog_add_button(GTK_DIALOG(dialog), | ||
53 | - GTK_STOCK_OK, GTK_RESPONSE_ACCEPT); | ||
54 | - gtk_widget_grab_default(button); | ||
55 | - | ||
56 | - table = gtk_table_new(5, 2, FALSE); | ||
57 | - gtk_table_set_row_spacings(GTK_TABLE(table), 4); | ||
58 | - gtk_table_set_col_spacings(GTK_TABLE(table), 20); | ||
59 | - gtk_container_set_border_width(GTK_CONTAINER(table), 12); | ||
60 | - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table); | ||
61 | - image = gtk_image_new_from_icon_name(GTK_STOCK_DIALOG_AUTHENTICATION, | ||
62 | - GTK_ICON_SIZE_DIALOG); | ||
63 | - gtk_misc_set_alignment(GTK_MISC(image), 0.0, 0.0); | ||
64 | - gtk_table_attach(GTK_TABLE(table), image, 0, 1, 0, 5, | ||
65 | - GTK_SHRINK, GTK_FILL, 0, 0); | ||
66 | - vbox = gtk_vbox_new(FALSE, 6); | ||
67 | - | ||
68 | - label = gtk_label_new(_("Network requires input of a passphrase:")); | ||
69 | - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); | ||
70 | - gtk_container_add(GTK_CONTAINER(vbox), label); | ||
71 | - gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 0, 1, | ||
72 | - GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0); | ||
73 | - | ||
74 | - entry = gtk_entry_new(); | ||
75 | - gtk_entry_set_max_length(GTK_ENTRY(entry), 120); | ||
76 | - gtk_entry_set_width_chars(GTK_ENTRY(entry), 20); | ||
77 | - gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); | ||
78 | - gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); | ||
79 | - gtk_container_add(GTK_CONTAINER(vbox), entry); | ||
80 | - | ||
81 | - button = gtk_check_button_new_with_label(_("Show input")); | ||
82 | - gtk_container_add(GTK_CONTAINER(vbox), button); | ||
83 | - | ||
84 | - g_signal_connect(G_OBJECT(button), "toggled", | ||
85 | - G_CALLBACK(toggled_callback), entry); | ||
86 | - | ||
87 | - button = gtk_check_button_new_with_label(_("Remember network")); | ||
88 | - gtk_container_add(GTK_CONTAINER(vbox), button); | ||
89 | - | ||
90 | - gtk_widget_show_all(dialog); | ||
91 | - | ||
92 | - if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { | ||
93 | - const gchar *passphrase; | ||
94 | - gboolean remember; | ||
95 | - | ||
96 | - passphrase = gtk_entry_get_text(GTK_ENTRY(entry)); | ||
97 | - remember = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); | ||
98 | - | ||
99 | - connman_client_set_passphrase(client, path, passphrase); | ||
100 | - connman_client_set_remember(client, path, remember); | ||
101 | - | ||
102 | - status_prepare(); | ||
103 | - connman_client_connect(client, path); | ||
104 | - } | ||
105 | - | ||
106 | - gtk_widget_destroy(dialog); | ||
107 | -} | ||
108 | - | ||
109 | -static void activate_callback(GtkWidget *item, gpointer user_data) | ||
110 | -{ | ||
111 | - const gchar *path = user_data; | ||
112 | - guint security; | ||
113 | - gchar *passphrase; | ||
114 | - | ||
115 | - security = connman_client_get_security(client, path); | ||
116 | - if (security == CONNMAN_SECURITY_UNKNOWN) | ||
117 | - return; | ||
118 | - | ||
119 | - if (security == CONNMAN_SECURITY_NONE) { | ||
120 | - status_prepare(); | ||
121 | - connman_client_connect(client, path); | ||
122 | - return; | ||
123 | - } | ||
124 | - | ||
125 | - passphrase = connman_client_get_passphrase(client, path); | ||
126 | - if (passphrase != NULL) { | ||
127 | - g_free(passphrase); | ||
128 | - | ||
129 | - status_prepare(); | ||
130 | - connman_client_connect(client, path); | ||
131 | - return; | ||
132 | - } | ||
133 | - | ||
134 | - passphrase_dialog(path, NULL); | ||
135 | -} | ||
136 | - | ||
137 | -static void disconnect_callback(GtkWidget *item, gpointer user_data) | ||
138 | -{ | ||
139 | - connman_client_disconnect(client, NULL); | ||
140 | -} | ||
141 | - | ||
142 | -static GtkWidget *create_popupmenu(void) | ||
143 | -{ | ||
144 | - GtkWidget *menu; | ||
145 | - GtkWidget *item; | ||
146 | - | ||
147 | - menu = gtk_menu_new(); | ||
148 | - | ||
149 | - item = gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES, NULL); | ||
150 | - g_signal_connect(item, "activate", G_CALLBACK(settings_callback), NULL); | ||
151 | - gtk_widget_show(item); | ||
152 | - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | ||
153 | - | ||
154 | - item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, NULL); | ||
155 | - g_signal_connect(item, "activate", G_CALLBACK(about_callback), NULL); | ||
156 | - gtk_widget_show(item); | ||
157 | - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | ||
158 | - | ||
159 | - return menu; | ||
160 | -} | ||
161 | - | ||
162 | -static GtkWidget *append_menuitem(GtkMenu *menu, const char *ssid, | ||
163 | - guint security, guint strength) | ||
164 | -{ | ||
165 | - GtkWidget *item; | ||
166 | - GtkWidget *hbox; | ||
167 | - GtkWidget *label; | ||
168 | - GtkWidget *image; | ||
169 | - GtkWidget *progress; | ||
170 | - | ||
171 | - item = gtk_check_menu_item_new(); | ||
172 | - gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM(item), TRUE); | ||
173 | - | ||
174 | - hbox = gtk_hbox_new(FALSE, 6); | ||
175 | - gtk_container_add(GTK_CONTAINER(item), hbox); | ||
176 | - gtk_widget_show(hbox); | ||
177 | - | ||
178 | - label = gtk_label_new(NULL); | ||
179 | - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | ||
180 | - gtk_label_set_text(GTK_LABEL(label), ssid); | ||
181 | - gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); | ||
182 | - gtk_widget_show(label); | ||
183 | - | ||
184 | - image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION, | ||
185 | - GTK_ICON_SIZE_MENU); | ||
186 | - gtk_misc_set_alignment(GTK_MISC(image), 1.0, 0.5); | ||
187 | - if (security != CONNMAN_SECURITY_NONE) { | ||
188 | - gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); | ||
189 | - gtk_widget_show(image); | ||
190 | - } | ||
191 | - | ||
192 | - progress = gtk_progress_bar_new(); | ||
193 | - gtk_widget_set_size_request(progress, 100, -1); | ||
194 | - gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), | ||
195 | - (double) strength / 100); | ||
196 | - gtk_box_pack_end(GTK_BOX(hbox), progress, FALSE, TRUE, 0); | ||
197 | - gtk_widget_show(progress); | ||
198 | - | ||
199 | - gtk_widget_show(item); | ||
200 | - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | ||
201 | - | ||
202 | - return item; | ||
203 | -} | ||
204 | - | ||
205 | -static void enumerate_networks(GtkMenu *menu, | ||
206 | - GtkTreeModel *model, GtkTreeIter *parent) | ||
207 | -{ | ||
208 | - GtkTreeIter iter; | ||
209 | - gboolean cont; | ||
210 | - | ||
211 | - cont = gtk_tree_model_iter_children(model, &iter, parent); | ||
212 | - | ||
213 | - while (cont == TRUE) { | ||
214 | - GtkWidget *item; | ||
215 | - DBusGProxy *proxy; | ||
216 | - guint strength, security; | ||
217 | - gchar *name, *path; | ||
218 | - gboolean inrange, connected; | ||
219 | - | ||
220 | - gtk_tree_model_get(model, &iter, | ||
221 | - CONNMAN_COLUMN_PROXY, &proxy, | ||
222 | - CONNMAN_COLUMN_NAME, &name, | ||
223 | - CONNMAN_COLUMN_INRANGE, &inrange, | ||
224 | - CONNMAN_COLUMN_ENABLED, &connected, | ||
225 | - CONNMAN_COLUMN_STRENGTH, &strength, | ||
226 | - CONNMAN_COLUMN_SECURITY, &security, -1); | ||
227 | - | ||
228 | - if (connected == TRUE || inrange == TRUE) { | ||
229 | - item = append_menuitem(menu, name, security, strength); | ||
230 | - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), | ||
231 | - connected); | ||
232 | - | ||
233 | - path = g_strdup(dbus_g_proxy_get_path(proxy)); | ||
234 | - g_signal_connect(item, "activate", | ||
235 | - G_CALLBACK(activate_callback), path); | ||
236 | - } | ||
237 | - | ||
238 | - g_free(name); | ||
239 | - | ||
240 | - cont = gtk_tree_model_iter_next(model, &iter); | ||
241 | - } | ||
242 | -} | ||
243 | - | ||
244 | static gboolean menu_callback(GtkMenu *menu) | ||
245 | { | ||
246 | - GtkTreeModel *model; | ||
247 | - GtkTreeIter parent; | ||
248 | GtkWidget *item; | ||
249 | - gboolean cont; | ||
250 | - | ||
251 | - connman_client_propose_scan(client, NULL); | ||
252 | - | ||
253 | - model = connman_client_get_device_network_model(client); | ||
254 | - | ||
255 | - cont = gtk_tree_model_get_iter_first(model, &parent); | ||
256 | - | ||
257 | - while (cont == TRUE) { | ||
258 | - guint type; | ||
259 | - gchar *name; | ||
260 | - | ||
261 | - gtk_tree_model_get(model, &parent, | ||
262 | - CONNMAN_COLUMN_TYPE, &type, | ||
263 | - CONNMAN_COLUMN_NAME, &name, -1); | ||
264 | - | ||
265 | - switch (type) { | ||
266 | - case CONNMAN_TYPE_WIFI: | ||
267 | - case CONNMAN_TYPE_WIMAX: | ||
268 | - enumerate_networks(menu, model, &parent); | ||
269 | - break; | ||
270 | - default: | ||
271 | - break; | ||
272 | - } | ||
273 | - | ||
274 | - g_free(name); | ||
275 | - | ||
276 | - cont = gtk_tree_model_iter_next(model, &parent); | ||
277 | - } | ||
278 | - | ||
279 | - g_object_unref(model); | ||
280 | |||
281 | item = gtk_separator_menu_item_new(); | ||
282 | gtk_widget_show(item); | ||
283 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | ||
284 | |||
285 | - item = gtk_menu_item_new_with_label(_("Disconnect Network")); | ||
286 | - g_signal_connect(item, "activate", | ||
287 | - G_CALLBACK(disconnect_callback), NULL); | ||
288 | + item = gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES, NULL); | ||
289 | + g_signal_connect(item, "activate", G_CALLBACK(settings_callback), NULL); | ||
290 | gtk_widget_show(item); | ||
291 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | ||
292 | |||
293 | - item = gtk_menu_item_new_with_label(_("Join Other Network...")); | ||
294 | - gtk_widget_set_sensitive(item, FALSE); | ||
295 | - //g_signal_connect(item, "activate", | ||
296 | - // G_CALLBACK(join_callback), NULL); | ||
297 | + item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, NULL); | ||
298 | + g_signal_connect(item, "activate", G_CALLBACK(about_callback), NULL); | ||
299 | gtk_widget_show(item); | ||
300 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | ||
301 | |||
302 | @@ -387,16 +129,17 @@ static void update_status(GtkTreeModel *model) | ||
303 | cont = gtk_tree_model_get_iter_first(model, &iter); | ||
304 | |||
305 | while (cont == TRUE) { | ||
306 | - gboolean enabled; | ||
307 | + gchar *state; | ||
308 | |||
309 | gtk_tree_model_get(model, &iter, | ||
310 | CONNMAN_COLUMN_TYPE, &type, | ||
311 | CONNMAN_COLUMN_STRENGTH, &strength, | ||
312 | - CONNMAN_COLUMN_ENABLED, &enabled, -1); | ||
313 | + CONNMAN_COLUMN_STATE, &state, -1); | ||
314 | |||
315 | online = TRUE; | ||
316 | |||
317 | - if (enabled == TRUE) | ||
318 | + if ((type == CONNMAN_TYPE_ETHERNET && (g_str_equal(state, "idle") || g_str_equal(state, "online"))) || | ||
319 | + (type == CONNMAN_TYPE_WIFI && (g_str_equal(state, "ready") || g_str_equal(state, "online")))) | ||
320 | break; | ||
321 | |||
322 | cont = gtk_tree_model_iter_next(model, &iter); | ||
323 | @@ -453,7 +196,7 @@ int main(int argc, char *argv[]) | ||
324 | |||
325 | g_set_application_name(_("Connection Manager")); | ||
326 | |||
327 | - status_init(menu_callback, create_popupmenu()); | ||
328 | + status_init(menu_callback); | ||
329 | |||
330 | client = connman_client_new(); | ||
331 | model = connman_client_get_connection_model(client); | ||
332 | diff --git a/applet/status.c b/applet/status.c | ||
333 | index ef11bcc..13ec752 100644 | ||
334 | --- a/applet/status.c | ||
335 | +++ b/applet/status.c | ||
336 | @@ -170,19 +170,6 @@ static void activate_callback(GObject *object, gpointer user_data) | ||
337 | GTK_STATUS_ICON(object), 1, activate_time); | ||
338 | } | ||
339 | |||
340 | -static void popup_callback(GObject *object, guint button, | ||
341 | - guint activate_time, gpointer user_data) | ||
342 | -{ | ||
343 | - GtkMenu *menu = user_data; | ||
344 | - | ||
345 | - if (menu == NULL) | ||
346 | - return; | ||
347 | - | ||
348 | - gtk_menu_popup(menu, NULL, NULL, | ||
349 | - gtk_status_icon_position_menu, | ||
350 | - GTK_STATUS_ICON(object), button, activate_time); | ||
351 | -} | ||
352 | - | ||
353 | static GtkIconTheme *icontheme; | ||
354 | static IconAnimation *animation; | ||
355 | static GdkPixbuf *pixbuf_notifier; | ||
356 | @@ -190,7 +177,7 @@ static GdkPixbuf *pixbuf_none; | ||
357 | static GdkPixbuf *pixbuf_wired; | ||
358 | static GdkPixbuf *pixbuf_signal[5]; | ||
359 | |||
360 | -int status_init(StatusCallback activate, GtkWidget *popup) | ||
361 | +int status_init(StatusCallback activate) | ||
362 | { | ||
363 | GdkScreen *screen; | ||
364 | |||
365 | @@ -219,9 +206,6 @@ int status_init(StatusCallback activate, GtkWidget *popup) | ||
366 | g_signal_connect(statusicon, "activate", | ||
367 | G_CALLBACK(activate_callback), activate); | ||
368 | |||
369 | - g_signal_connect(statusicon, "popup-menu", | ||
370 | - G_CALLBACK(popup_callback), popup); | ||
371 | - | ||
372 | return 0; | ||
373 | } | ||
374 | |||
375 | @@ -292,8 +276,6 @@ void status_config(void) | ||
376 | |||
377 | static void set_ready(gint signal) | ||
378 | { | ||
379 | - int index; | ||
380 | - | ||
381 | available = TRUE; | ||
382 | |||
383 | if (signal < 0) { | ||
384 | @@ -302,12 +284,7 @@ static void set_ready(gint signal) | ||
385 | return; | ||
386 | } | ||
387 | |||
388 | - if (signal == 0) | ||
389 | - index = 0; | ||
390 | - else | ||
391 | - index = 3; | ||
392 | - | ||
393 | - gtk_status_icon_set_from_pixbuf(statusicon, pixbuf_signal[index]); | ||
394 | + gtk_status_icon_set_from_pixbuf(statusicon, pixbuf_signal[4]); | ||
395 | gtk_status_icon_set_tooltip(statusicon, NULL); | ||
396 | } | ||
397 | |||
398 | diff --git a/applet/status.h b/applet/status.h | ||
399 | index 772a7b2..8a3c83c 100644 | ||
400 | --- a/applet/status.h | ||
401 | +++ b/applet/status.h | ||
402 | @@ -21,7 +21,7 @@ | ||
403 | |||
404 | typedef gboolean (* StatusCallback) (GtkMenu *menu); | ||
405 | |||
406 | -int status_init(StatusCallback activate, GtkWidget *popup); | ||
407 | +int status_init(StatusCallback activate); | ||
408 | void status_cleanup(void); | ||
409 | |||
410 | void status_unavailable(void); | ||
411 | diff --git a/common/Makefile.am b/common/Makefile.am | ||
412 | index ff3a996..8d74a46 100644 | ||
413 | --- a/common/Makefile.am | ||
414 | +++ b/common/Makefile.am | ||
415 | @@ -5,13 +5,6 @@ libcommon_a_SOURCES = connman-dbus.c connman-dbus.h \ | ||
416 | connman-client.h connman-client.c \ | ||
417 | instance.h instance.c | ||
418 | |||
419 | -noinst_PROGRAMS = connman-demo test-client | ||
420 | - | ||
421 | -connman_demo_SOURCES = demo.c | ||
422 | -connman_demo_LDADD = libcommon.a @GTK_LIBS@ @DBUS_LIBS@ | ||
423 | - | ||
424 | -test_client_LDADD = libcommon.a @GTK_LIBS@ @DBUS_LIBS@ | ||
425 | - | ||
426 | BUILT_SOURCES = marshal.h marshal.c \ | ||
427 | connman-dbus-glue.h \ | ||
428 | instance-glue.h | ||
429 | diff --git a/common/connman-client.c b/common/connman-client.c | ||
430 | index aad0a22..4f9cf64 100644 | ||
431 | --- a/common/connman-client.c | ||
432 | +++ b/common/connman-client.c | ||
433 | @@ -98,13 +98,13 @@ static void connman_client_init(ConnmanClient *client) | ||
434 | |||
435 | priv->store = gtk_tree_store_new(_CONNMAN_NUM_COLUMNS, G_TYPE_OBJECT, | ||
436 | G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, | ||
437 | - G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, | ||
438 | - G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING, | ||
439 | - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, | ||
440 | - G_TYPE_STRING); | ||
441 | + G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, | ||
442 | + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, | ||
443 | + G_TYPE_STRING, G_TYPE_STRING, | ||
444 | + G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN); | ||
445 | |||
446 | g_object_set_data(G_OBJECT(priv->store), | ||
447 | - "State", g_strdup("unavailable")); | ||
448 | + "State", g_strdup("unavailable")); | ||
449 | |||
450 | priv->dbus = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, | ||
451 | DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); | ||
452 | @@ -191,13 +191,23 @@ static gboolean device_filter(GtkTreeModel *model, | ||
453 | { | ||
454 | DBusGProxy *proxy; | ||
455 | gboolean active; | ||
456 | + guint type; | ||
457 | |||
458 | - gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy, -1); | ||
459 | + gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy, | ||
460 | + CONNMAN_COLUMN_TYPE, &type, | ||
461 | + -1); | ||
462 | + | ||
463 | + switch (type) { | ||
464 | + case CONNMAN_TYPE_LABEL_ETHERNET: | ||
465 | + case CONNMAN_TYPE_LABEL_WIFI: | ||
466 | + case CONNMAN_TYPE_SYSCONFIG: | ||
467 | + return TRUE; | ||
468 | + } | ||
469 | |||
470 | if (proxy == NULL) | ||
471 | return FALSE; | ||
472 | |||
473 | - active = g_str_equal(CONNMAN_DEVICE_INTERFACE, | ||
474 | + active = g_str_equal(CONNMAN_SERVICE_INTERFACE, | ||
475 | dbus_g_proxy_get_interface(proxy)); | ||
476 | |||
477 | g_object_unref(proxy); | ||
478 | @@ -231,10 +241,10 @@ static gboolean device_network_filter(GtkTreeModel *model, | ||
479 | if (proxy == NULL) | ||
480 | return FALSE; | ||
481 | |||
482 | - active = g_str_equal(CONNMAN_DEVICE_INTERFACE, | ||
483 | + active = g_str_equal(CONNMAN_SERVICE_INTERFACE, | ||
484 | dbus_g_proxy_get_interface(proxy)); | ||
485 | if (active == FALSE) | ||
486 | - active = g_str_equal(CONNMAN_NETWORK_INTERFACE, | ||
487 | + active = g_str_equal(CONNMAN_SERVICE_INTERFACE, | ||
488 | dbus_g_proxy_get_interface(proxy)); | ||
489 | |||
490 | g_object_unref(proxy); | ||
491 | @@ -277,7 +287,7 @@ GtkTreeModel *connman_client_get_network_model(ConnmanClient *client, | ||
492 | gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter, | ||
493 | CONNMAN_COLUMN_PROXY, &proxy, -1); | ||
494 | |||
495 | - if (g_str_equal(CONNMAN_DEVICE_INTERFACE, | ||
496 | + if (g_str_equal(CONNMAN_SERVICE_INTERFACE, | ||
497 | dbus_g_proxy_get_interface(proxy)) == TRUE) | ||
498 | found = g_str_has_prefix(dbus_g_proxy_get_path(proxy), | ||
499 | device); | ||
500 | @@ -314,7 +324,7 @@ static gboolean connection_filter(GtkTreeModel *model, | ||
501 | if (proxy == NULL) | ||
502 | return FALSE; | ||
503 | |||
504 | - active = g_str_equal(CONNMAN_CONNECTION_INTERFACE, | ||
505 | + active = g_str_equal(CONNMAN_SERVICE_INTERFACE, | ||
506 | dbus_g_proxy_get_interface(proxy)); | ||
507 | |||
508 | g_object_unref(proxy); | ||
509 | @@ -337,28 +347,37 @@ GtkTreeModel *connman_client_get_connection_model(ConnmanClient *client) | ||
510 | return model; | ||
511 | } | ||
512 | |||
513 | -void connman_client_set_policy(ConnmanClient *client, const gchar *device, | ||
514 | - const gchar *policy) | ||
515 | +gboolean connman_client_set_ipv4(ConnmanClient *client, const gchar *device, | ||
516 | + struct ipv4_config *ipv4_config) | ||
517 | { | ||
518 | ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); | ||
519 | DBusGProxy *proxy; | ||
520 | GValue value = { 0 }; | ||
521 | + gboolean ret; | ||
522 | + GHashTable *ipv4 = g_hash_table_new(g_str_hash, g_str_equal); | ||
523 | + | ||
524 | + g_hash_table_insert(ipv4, "Method", (gpointer)ipv4_config->method); | ||
525 | + g_hash_table_insert(ipv4, "Address", (gpointer)ipv4_config->address); | ||
526 | + g_hash_table_insert(ipv4, "Netmask", (gpointer)ipv4_config->netmask); | ||
527 | + g_hash_table_insert(ipv4, "Gateway", (gpointer)ipv4_config->gateway); | ||
528 | |||
529 | DBG("client %p", client); | ||
530 | |||
531 | if (device == NULL) | ||
532 | - return; | ||
533 | + return FALSE; | ||
534 | |||
535 | proxy = connman_dbus_get_proxy(priv->store, device); | ||
536 | if (proxy == NULL) | ||
537 | - return; | ||
538 | + return FALSE; | ||
539 | |||
540 | - g_value_init(&value, G_TYPE_STRING); | ||
541 | - g_value_set_string(&value, policy); | ||
542 | + g_value_init(&value, DBUS_TYPE_G_STRING_STRING_HASHTABLE); | ||
543 | + g_value_set_boxed(&value, ipv4); | ||
544 | |||
545 | - connman_set_property(proxy, "Policy", &value, NULL); | ||
546 | + ret = connman_set_property(proxy, "IPv4.Configuration", &value, NULL); | ||
547 | |||
548 | g_object_unref(proxy); | ||
549 | + | ||
550 | + return ret; | ||
551 | } | ||
552 | |||
553 | void connman_client_set_powered(ConnmanClient *client, const gchar *device, | ||
554 | @@ -385,98 +404,128 @@ void connman_client_set_powered(ConnmanClient *client, const gchar *device, | ||
555 | g_object_unref(proxy); | ||
556 | } | ||
557 | |||
558 | -static gboolean device_scan(GtkTreeModel *model, GtkTreePath *path, | ||
559 | - GtkTreeIter *iter, gpointer user_data) | ||
560 | +void connman_client_request_scan(ConnmanClient *client, char *scantype, | ||
561 | + connman_request_scan_reply callback, gpointer userdata) | ||
562 | { | ||
563 | - DBusGProxy *proxy; | ||
564 | - gboolean enabled; | ||
565 | + ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); | ||
566 | |||
567 | - gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy, | ||
568 | - CONNMAN_COLUMN_ENABLED, &enabled, -1); | ||
569 | + DBG("client %p", client); | ||
570 | |||
571 | - if (proxy == NULL) | ||
572 | - return FALSE; | ||
573 | + connman_request_scan_async(priv->manager, scantype, callback, userdata); | ||
574 | +} | ||
575 | |||
576 | - if (g_str_equal(dbus_g_proxy_get_interface(proxy), | ||
577 | - CONNMAN_DEVICE_INTERFACE) == FALSE) | ||
578 | - return FALSE; | ||
579 | +gboolean connman_client_get_offline_status(ConnmanClient *client) | ||
580 | +{ | ||
581 | + GHashTable *hash; | ||
582 | + GValue *value; | ||
583 | + ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); | ||
584 | + gboolean ret; | ||
585 | |||
586 | - if (enabled == FALSE) | ||
587 | - return FALSE; | ||
588 | + DBG("client %p", client); | ||
589 | |||
590 | - connman_propose_scan(proxy, NULL); | ||
591 | + ret = connman_get_properties(priv->manager, &hash, NULL); | ||
592 | |||
593 | - g_object_unref(proxy); | ||
594 | + if (ret == FALSE) | ||
595 | + goto done; | ||
596 | + | ||
597 | + value = g_hash_table_lookup(hash, "OfflineMode"); | ||
598 | + ret = value ? g_value_get_boolean(value) : FALSE; | ||
599 | + | ||
600 | +done: | ||
601 | + return ret; | ||
602 | |||
603 | - return FALSE; | ||
604 | } | ||
605 | |||
606 | -void connman_client_propose_scan(ConnmanClient *client, const gchar *device) | ||
607 | +void connman_client_set_offlinemode(ConnmanClient *client, gboolean status) | ||
608 | { | ||
609 | ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); | ||
610 | - DBusGProxy *proxy; | ||
611 | + GValue value = { 0 }; | ||
612 | |||
613 | DBG("client %p", client); | ||
614 | |||
615 | - if (device == NULL) { | ||
616 | - gtk_tree_model_foreach(GTK_TREE_MODEL(priv->store), | ||
617 | - device_scan, NULL); | ||
618 | - return; | ||
619 | - } | ||
620 | - | ||
621 | - proxy = connman_dbus_get_proxy(priv->store, device); | ||
622 | - if (proxy == NULL) | ||
623 | - return; | ||
624 | - | ||
625 | - connman_propose_scan(proxy, NULL); | ||
626 | + g_value_init(&value, G_TYPE_BOOLEAN); | ||
627 | + g_value_set_boolean(&value, status); | ||
628 | |||
629 | - g_object_unref(proxy); | ||
630 | + connman_set_property(priv->manager, "OfflineMode", &value, NULL); | ||
631 | } | ||
632 | |||
633 | static gboolean network_disconnect(GtkTreeModel *model, GtkTreePath *path, | ||
634 | GtkTreeIter *iter, gpointer user_data) | ||
635 | { | ||
636 | DBusGProxy *proxy; | ||
637 | - gboolean enabled; | ||
638 | + char *name; | ||
639 | + guint type; | ||
640 | |||
641 | gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy, | ||
642 | - CONNMAN_COLUMN_ENABLED, &enabled, -1); | ||
643 | + CONNMAN_COLUMN_NAME, &name, | ||
644 | + CONNMAN_COLUMN_TYPE, &type, | ||
645 | + -1); | ||
646 | |||
647 | if (proxy == NULL) | ||
648 | - return FALSE; | ||
649 | + return TRUE; | ||
650 | |||
651 | if (g_str_equal(dbus_g_proxy_get_interface(proxy), | ||
652 | - CONNMAN_NETWORK_INTERFACE) == FALSE) | ||
653 | - return FALSE; | ||
654 | + CONNMAN_SERVICE_INTERFACE) == FALSE) | ||
655 | + return TRUE; | ||
656 | |||
657 | - if (enabled == TRUE) | ||
658 | + if (type == CONNMAN_TYPE_WIFI) | ||
659 | connman_disconnect(proxy, NULL); | ||
660 | |||
661 | g_object_unref(proxy); | ||
662 | |||
663 | - return enabled; | ||
664 | + return FALSE; | ||
665 | } | ||
666 | |||
667 | -void connman_client_connect(ConnmanClient *client, const gchar *network) | ||
668 | +gboolean connman_client_connect(ConnmanClient *client, const gchar *network) | ||
669 | { | ||
670 | ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); | ||
671 | DBusGProxy *proxy; | ||
672 | + gboolean ret = FALSE; | ||
673 | |||
674 | DBG("client %p", client); | ||
675 | + DBG("network %s", network); | ||
676 | |||
677 | if (network == NULL) | ||
678 | - return; | ||
679 | + goto done; | ||
680 | |||
681 | gtk_tree_model_foreach(GTK_TREE_MODEL(priv->store), | ||
682 | network_disconnect, NULL); | ||
683 | |||
684 | proxy = connman_dbus_get_proxy(priv->store, network); | ||
685 | if (proxy == NULL) | ||
686 | - return; | ||
687 | + goto done; | ||
688 | |||
689 | - connman_connect(proxy, NULL); | ||
690 | + ret = connman_connect(proxy, NULL); | ||
691 | |||
692 | g_object_unref(proxy); | ||
693 | + | ||
694 | +done: | ||
695 | + return ret; | ||
696 | +} | ||
697 | + | ||
698 | +void connman_client_connect_async(ConnmanClient *client, const gchar *network, | ||
699 | + connman_connect_reply callback, gpointer userdata) | ||
700 | +{ | ||
701 | + ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); | ||
702 | + DBusGProxy *proxy; | ||
703 | + | ||
704 | + DBG("client %p", client); | ||
705 | + DBG("network %s", network); | ||
706 | + | ||
707 | + if (network == NULL) | ||
708 | + goto done; | ||
709 | + | ||
710 | + gtk_tree_model_foreach(GTK_TREE_MODEL(priv->store), | ||
711 | + network_disconnect, NULL); | ||
712 | + | ||
713 | + proxy = connman_dbus_get_proxy(priv->store, network); | ||
714 | + if (proxy == NULL) | ||
715 | + goto done; | ||
716 | + | ||
717 | + connman_connect_async(proxy, callback, userdata); | ||
718 | + | ||
719 | +done: | ||
720 | + return; | ||
721 | } | ||
722 | |||
723 | static void connman_client_disconnect_all(ConnmanClient *client) | ||
724 | @@ -487,32 +536,37 @@ static void connman_client_disconnect_all(ConnmanClient *client) | ||
725 | network_disconnect, NULL); | ||
726 | } | ||
727 | |||
728 | -void connman_client_disconnect(ConnmanClient *client, const gchar *network) | ||
729 | +gboolean connman_client_disconnect(ConnmanClient *client, const gchar *network) | ||
730 | { | ||
731 | ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); | ||
732 | DBusGProxy *proxy; | ||
733 | + gboolean ret = FALSE; | ||
734 | |||
735 | DBG("client %p", client); | ||
736 | |||
737 | if (network == NULL) { | ||
738 | + ret = TRUE; | ||
739 | connman_client_disconnect_all(client); | ||
740 | - return; | ||
741 | + goto done; | ||
742 | } | ||
743 | |||
744 | proxy = connman_dbus_get_proxy(priv->store, network); | ||
745 | if (proxy == NULL) | ||
746 | - return; | ||
747 | + goto done; | ||
748 | |||
749 | - connman_disconnect(proxy, NULL); | ||
750 | + ret = connman_disconnect(proxy, NULL); | ||
751 | |||
752 | g_object_unref(proxy); | ||
753 | + | ||
754 | +done: | ||
755 | + return ret; | ||
756 | } | ||
757 | |||
758 | -guint connman_client_get_security(ConnmanClient *client, const gchar *network) | ||
759 | +gchar *connman_client_get_security(ConnmanClient *client, const gchar *network) | ||
760 | { | ||
761 | ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); | ||
762 | GtkTreeIter iter; | ||
763 | - guint security; | ||
764 | + gchar *security; | ||
765 | |||
766 | DBG("client %p", client); | ||
767 | |||
768 | @@ -548,41 +602,60 @@ gchar *connman_client_get_passphrase(ConnmanClient *client, const gchar *network | ||
769 | return passphrase; | ||
770 | } | ||
771 | |||
772 | -void connman_client_set_passphrase(ConnmanClient *client, const gchar *network, | ||
773 | +gboolean connman_client_set_passphrase(ConnmanClient *client, const gchar *network, | ||
774 | const gchar *passphrase) | ||
775 | { | ||
776 | ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); | ||
777 | DBusGProxy *proxy; | ||
778 | GValue value = { 0 }; | ||
779 | + gboolean ret = FALSE; | ||
780 | |||
781 | DBG("client %p", client); | ||
782 | + DBG("network %p", network); | ||
783 | |||
784 | if (network == NULL) | ||
785 | - return; | ||
786 | + goto done; | ||
787 | |||
788 | proxy = connman_dbus_get_proxy(priv->store, network); | ||
789 | if (proxy == NULL) | ||
790 | - return; | ||
791 | + goto done; | ||
792 | |||
793 | g_value_init(&value, G_TYPE_STRING); | ||
794 | g_value_set_string(&value, passphrase); | ||
795 | |||
796 | - connman_set_property(proxy, "WiFi.Passphrase", &value, NULL); | ||
797 | + ret = connman_set_property(proxy, "Passphrase", &value, NULL); | ||
798 | |||
799 | g_value_unset(&value); | ||
800 | |||
801 | g_object_unref(proxy); | ||
802 | +done: | ||
803 | + return ret; | ||
804 | } | ||
805 | |||
806 | -void connman_client_set_remember(ConnmanClient *client, const gchar *network, | ||
807 | - gboolean remember) | ||
808 | +void connman_client_set_callback(ConnmanClient *client, | ||
809 | + ConnmanClientCallback callback, gpointer user_data) | ||
810 | { | ||
811 | ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); | ||
812 | - DBusGProxy *proxy; | ||
813 | - GValue value = { 0 }; | ||
814 | + gchar *state; | ||
815 | |||
816 | DBG("client %p", client); | ||
817 | |||
818 | + priv->callback = callback; | ||
819 | + priv->userdata = user_data; | ||
820 | + | ||
821 | + g_object_set_data(G_OBJECT(priv->store), "callback", callback); | ||
822 | + g_object_set_data(G_OBJECT(priv->store), "userdata", user_data); | ||
823 | + | ||
824 | + state = g_object_get_data(G_OBJECT(priv->store), "State"); | ||
825 | + if (state != NULL && priv->callback != NULL) | ||
826 | + priv->callback(state, priv->userdata); | ||
827 | +} | ||
828 | + | ||
829 | +void connman_client_remove(ConnmanClient *client, const gchar *network) | ||
830 | +{ | ||
831 | + ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); | ||
832 | + DBusGProxy *proxy; | ||
833 | + | ||
834 | if (network == NULL) | ||
835 | return; | ||
836 | |||
837 | @@ -590,31 +663,46 @@ void connman_client_set_remember(ConnmanClient *client, const gchar *network, | ||
838 | if (proxy == NULL) | ||
839 | return; | ||
840 | |||
841 | - g_value_init(&value, G_TYPE_BOOLEAN); | ||
842 | - g_value_set_boolean(&value, remember); | ||
843 | + connman_remove(proxy, NULL); | ||
844 | + | ||
845 | + g_object_unref(proxy); | ||
846 | +} | ||
847 | + | ||
848 | +void connman_client_enable_technology(ConnmanClient *client, const char *network, | ||
849 | + const gchar *technology) | ||
850 | +{ | ||
851 | + ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); | ||
852 | + DBusGProxy *proxy; | ||
853 | + int ret; | ||
854 | |||
855 | - connman_set_property(proxy, "Remember", &value, NULL); | ||
856 | + if (network== NULL) | ||
857 | + return; | ||
858 | |||
859 | - g_value_unset(&value); | ||
860 | + proxy = connman_dbus_get_proxy(priv->store, network); | ||
861 | + if (proxy == NULL) | ||
862 | + return; | ||
863 | + | ||
864 | + ret = connman_enable_technology(proxy, technology, NULL); | ||
865 | |||
866 | g_object_unref(proxy); | ||
867 | } | ||
868 | |||
869 | -void connman_client_set_callback(ConnmanClient *client, | ||
870 | - ConnmanClientCallback callback, gpointer user_data) | ||
871 | +void connman_client_disable_technology(ConnmanClient *client, const char *network, | ||
872 | + const gchar *technology) | ||
873 | { | ||
874 | ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); | ||
875 | - gchar *state; | ||
876 | + DBusGProxy *proxy; | ||
877 | + int ret; | ||
878 | |||
879 | - DBG("client %p", client); | ||
880 | |||
881 | - priv->callback = callback; | ||
882 | - priv->userdata = user_data; | ||
883 | + if (network == NULL) | ||
884 | + return; | ||
885 | |||
886 | - g_object_set_data(G_OBJECT(priv->store), "callback", callback); | ||
887 | - g_object_set_data(G_OBJECT(priv->store), "userdata", user_data); | ||
888 | + proxy = connman_dbus_get_proxy(priv->store, network); | ||
889 | + if (proxy == NULL) | ||
890 | + return; | ||
891 | |||
892 | - state = g_object_get_data(G_OBJECT(priv->store), "State"); | ||
893 | - if (state != NULL && priv->callback != NULL) | ||
894 | - priv->callback(state, priv->userdata); | ||
895 | + ret = connman_disable_technology(proxy, technology, NULL); | ||
896 | + | ||
897 | + g_object_unref(proxy); | ||
898 | } | ||
899 | diff --git a/common/connman-client.h b/common/connman-client.h | ||
900 | index f30dae4..00c328a 100644 | ||
901 | --- a/common/connman-client.h | ||
902 | +++ b/common/connman-client.h | ||
903 | @@ -23,6 +23,7 @@ | ||
904 | #define __CONNMAN_CLIENT_H | ||
905 | |||
906 | #include <gtk/gtk.h> | ||
907 | +#include "connman-dbus-glue.h" | ||
908 | |||
909 | G_BEGIN_DECLS | ||
910 | |||
911 | @@ -49,6 +50,13 @@ struct _ConnmanClientClass { | ||
912 | GObjectClass parent_class; | ||
913 | }; | ||
914 | |||
915 | +struct ipv4_config { | ||
916 | + const gchar *method; | ||
917 | + const gchar *address; | ||
918 | + const gchar *netmask; | ||
919 | + const gchar *gateway; | ||
920 | +}; | ||
921 | + | ||
922 | GType connman_client_get_type(void); | ||
923 | |||
924 | ConnmanClient *connman_client_new(void); | ||
925 | @@ -60,18 +68,20 @@ GtkTreeModel *connman_client_get_network_model(ConnmanClient *client, | ||
926 | const gchar *device); | ||
927 | GtkTreeModel *connman_client_get_connection_model(ConnmanClient *client); | ||
928 | |||
929 | -void connman_client_set_policy(ConnmanClient *client, const gchar *device, | ||
930 | - const gchar *policy); | ||
931 | void connman_client_set_powered(ConnmanClient *client, const gchar *device, | ||
932 | gboolean powered); | ||
933 | void connman_client_propose_scan(ConnmanClient *client, const gchar *device); | ||
934 | |||
935 | -void connman_client_connect(ConnmanClient *client, const gchar *network); | ||
936 | -void connman_client_disconnect(ConnmanClient *client, const gchar *network); | ||
937 | +gboolean connman_client_connect(ConnmanClient *client, const gchar *network); | ||
938 | + | ||
939 | +void connman_client_connect_async(ConnmanClient *client, const gchar *network, | ||
940 | + connman_connect_reply callback, gpointer userdata); | ||
941 | |||
942 | -guint connman_client_get_security(ConnmanClient *client, const gchar *network); | ||
943 | +gboolean connman_client_disconnect(ConnmanClient *client, const gchar *network); | ||
944 | + | ||
945 | +gchar *connman_client_get_security(ConnmanClient *client, const gchar *network); | ||
946 | gchar *connman_client_get_passphrase(ConnmanClient *client, const gchar *network); | ||
947 | -void connman_client_set_passphrase(ConnmanClient *client, const gchar *network, | ||
948 | +gboolean connman_client_set_passphrase(ConnmanClient *client, const gchar *network, | ||
949 | const gchar *passphrase); | ||
950 | void connman_client_set_remember(ConnmanClient *client, const gchar *network, | ||
951 | gboolean remember); | ||
952 | @@ -81,37 +91,63 @@ typedef void (* ConnmanClientCallback) (const char *status, void *user_data); | ||
953 | void connman_client_set_callback(ConnmanClient *client, | ||
954 | ConnmanClientCallback callback, gpointer user_data); | ||
955 | |||
956 | +gboolean connman_client_set_ipv4(ConnmanClient *client, const gchar *device, | ||
957 | + struct ipv4_config *ipv4_config); | ||
958 | + | ||
959 | +gboolean connman_dbus_get_iter(GtkTreeStore *store, const gchar *path, | ||
960 | + GtkTreeIter *iter); | ||
961 | +void connman_client_remove(ConnmanClient *client, const gchar *network); | ||
962 | + | ||
963 | +void connman_client_request_scan(ConnmanClient *client, char *scantype, | ||
964 | + connman_request_scan_reply callback, gpointer userdata); | ||
965 | +gboolean connman_client_get_offline_status(ConnmanClient *client); | ||
966 | +void connman_client_set_offlinemode(ConnmanClient *client, gboolean status); | ||
967 | + | ||
968 | +void connman_client_enable_technology(ConnmanClient *client, const char *network, | ||
969 | + const gchar *technology); | ||
970 | +void connman_client_disable_technology(ConnmanClient *client, const char *network, | ||
971 | + const gchar *technology); | ||
972 | enum { | ||
973 | CONNMAN_COLUMN_PROXY, /* G_TYPE_OBJECT */ | ||
974 | + CONNMAN_COLUMN_STATE, /* G_TYPE_STRING */ | ||
975 | CONNMAN_COLUMN_NAME, /* G_TYPE_STRING */ | ||
976 | - CONNMAN_COLUMN_ICON, /* G_TYPE_STRING */ | ||
977 | CONNMAN_COLUMN_TYPE, /* G_TYPE_UINT */ | ||
978 | - CONNMAN_COLUMN_ENABLED, /* G_TYPE_BOOLEAN */ | ||
979 | - CONNMAN_COLUMN_INRANGE, /* G_TYPE_BOOLEAN */ | ||
980 | - CONNMAN_COLUMN_REMEMBER, /* G_TYPE_BOOLEAN */ | ||
981 | + CONNMAN_COLUMN_ICON, /* G_TYPE_STRING */ | ||
982 | CONNMAN_COLUMN_STRENGTH, /* G_TYPE_UINT */ | ||
983 | - CONNMAN_COLUMN_SECURITY, /* G_TYPE_UINT */ | ||
984 | + CONNMAN_COLUMN_SECURITY, /* G_TYPE_STRING */ | ||
985 | CONNMAN_COLUMN_PASSPHRASE, /* G_TYPE_STRING */ | ||
986 | - CONNMAN_COLUMN_NETWORK, | ||
987 | - CONNMAN_COLUMN_ADDRESS, | ||
988 | - CONNMAN_COLUMN_POLICY, | ||
989 | - CONNMAN_COLUMN_DEVICE, | ||
990 | - _CONNMAN_NUM_COLUMNS | ||
991 | + | ||
992 | + CONNMAN_COLUMN_METHOD, /* G_TYPE_STRING */ | ||
993 | + CONNMAN_COLUMN_ADDRESS, /* G_TYPE_STRING */ | ||
994 | + CONNMAN_COLUMN_NETMASK, /* G_TYPE_STRING */ | ||
995 | + CONNMAN_COLUMN_GATEWAY, /* G_TYPE_STRING */ | ||
996 | + | ||
997 | + CONNMAN_COLUMN_ETHERNET_ENABLED, /* G_TYPE_BOOLEAN */ | ||
998 | + CONNMAN_COLUMN_WIFI_ENABLED, /* G_TYPE_BOOLEAN */ | ||
999 | + | ||
1000 | + CONNMAN_COLUMN_OFFLINEMODE, /* G_TYPE_BOOLEAN */ | ||
1001 | + | ||
1002 | + _CONNMAN_NUM_COLUMNS, | ||
1003 | + | ||
1004 | }; | ||
1005 | |||
1006 | enum { | ||
1007 | CONNMAN_TYPE_UNKNOWN, | ||
1008 | + | ||
1009 | CONNMAN_TYPE_ETHERNET, | ||
1010 | CONNMAN_TYPE_WIFI, | ||
1011 | CONNMAN_TYPE_WIMAX, | ||
1012 | CONNMAN_TYPE_BLUETOOTH, | ||
1013 | + | ||
1014 | + CONNMAN_TYPE_LABEL_ETHERNET, | ||
1015 | + CONNMAN_TYPE_LABEL_WIFI, | ||
1016 | + | ||
1017 | + CONNMAN_TYPE_SYSCONFIG, | ||
1018 | + _CONNMAN_NUM_TYPE, | ||
1019 | }; | ||
1020 | |||
1021 | enum { | ||
1022 | - CONNMAN_POLICY_UNKNOWN, | ||
1023 | - CONNMAN_POLICY_IGNORE, | ||
1024 | - CONNMAN_POLICY_OFF, | ||
1025 | - CONNMAN_POLICY_AUTO, | ||
1026 | + CONNMAN_POLICY_DHCP, | ||
1027 | CONNMAN_POLICY_MANUAL, | ||
1028 | }; | ||
1029 | |||
1030 | diff --git a/common/connman-dbus.c b/common/connman-dbus.c | ||
1031 | index 9eba7ae..bf1778f 100644 | ||
1032 | --- a/common/connman-dbus.c | ||
1033 | +++ b/common/connman-dbus.c | ||
1034 | @@ -137,6 +137,27 @@ DBusGProxy *connman_dbus_get_proxy(GtkTreeStore *store, const gchar *path) | ||
1035 | return proxy; | ||
1036 | } | ||
1037 | |||
1038 | +static gboolean compare_type(GtkTreeStore *store, GtkTreeIter *iter, | ||
1039 | + gconstpointer user_data) | ||
1040 | +{ | ||
1041 | + guint type_target = GPOINTER_TO_UINT(user_data); | ||
1042 | + guint type; | ||
1043 | + gboolean found = FALSE; | ||
1044 | + | ||
1045 | + gtk_tree_model_get(GTK_TREE_MODEL(store), iter, | ||
1046 | + CONNMAN_COLUMN_TYPE, &type, -1); | ||
1047 | + | ||
1048 | + if (type != CONNMAN_TYPE_UNKNOWN) | ||
1049 | + found = (type == type_target); | ||
1050 | + | ||
1051 | + return found; | ||
1052 | +} | ||
1053 | + | ||
1054 | +static gboolean get_iter_from_type(GtkTreeStore *store, GtkTreeIter *iter, guint type) | ||
1055 | +{ | ||
1056 | + return iter_search(store, iter, NULL, compare_type, GUINT_TO_POINTER(type)); | ||
1057 | +} | ||
1058 | + | ||
1059 | gboolean connman_dbus_get_iter(GtkTreeStore *store, const gchar *path, | ||
1060 | GtkTreeIter *iter) | ||
1061 | { | ||
1062 | @@ -167,12 +188,7 @@ static void property_update(GtkTreeStore *store, const GValue *value, | ||
1063 | |||
1064 | DBG("store %p key %s", store, key); | ||
1065 | |||
1066 | - if (g_str_equal(key, "Connections") == TRUE) | ||
1067 | - iface = CONNMAN_CONNECTION_INTERFACE; | ||
1068 | - else if (g_str_equal(key, "Devices") == TRUE) | ||
1069 | - iface = CONNMAN_DEVICE_INTERFACE; | ||
1070 | - else | ||
1071 | - iface = CONNMAN_NETWORK_INTERFACE; | ||
1072 | + iface = CONNMAN_SERVICE_INTERFACE; | ||
1073 | |||
1074 | old_list = g_object_get_data(G_OBJECT(store), key); | ||
1075 | |||
1076 | @@ -205,25 +221,12 @@ static void property_update(GtkTreeStore *store, const GValue *value, | ||
1077 | for (list = old_list; list; list = list->next) { | ||
1078 | gchar *path = list->data; | ||
1079 | GtkTreeIter iter; | ||
1080 | - gchar *device = NULL; | ||
1081 | |||
1082 | DBG("old path %s", path); | ||
1083 | |||
1084 | - if (get_iter_from_path(store, &iter, path) == TRUE) { | ||
1085 | - if (g_str_equal(key, "Connections") == TRUE) | ||
1086 | - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, | ||
1087 | - CONNMAN_COLUMN_DEVICE, &device, -1); | ||
1088 | - | ||
1089 | + if (get_iter_from_path(store, &iter, path) == TRUE) | ||
1090 | gtk_tree_store_remove(store, &iter); | ||
1091 | - } | ||
1092 | |||
1093 | - if (get_iter_from_path(store, &iter, device) == TRUE) { | ||
1094 | - gtk_tree_store_set(store, &iter, | ||
1095 | - CONNMAN_COLUMN_INRANGE, FALSE, | ||
1096 | - CONNMAN_COLUMN_ADDRESS, NULL, -1); | ||
1097 | - } | ||
1098 | - | ||
1099 | - g_free(device); | ||
1100 | g_free(path); | ||
1101 | } | ||
1102 | |||
1103 | @@ -263,155 +266,115 @@ static const gchar *type2icon(guint type) | ||
1104 | return NULL; | ||
1105 | } | ||
1106 | |||
1107 | -static guint get_policy(const GValue *value) | ||
1108 | -{ | ||
1109 | - const char *policy = value ? g_value_get_string(value) : NULL; | ||
1110 | - | ||
1111 | - if (policy == NULL) | ||
1112 | - return CONNMAN_POLICY_UNKNOWN; | ||
1113 | - else if (g_str_equal(policy, "ignore") == TRUE) | ||
1114 | - return CONNMAN_POLICY_IGNORE; | ||
1115 | - else if (g_str_equal(policy, "off") == TRUE) | ||
1116 | - return CONNMAN_POLICY_OFF; | ||
1117 | - else if (g_str_equal(policy, "auto") == TRUE) | ||
1118 | - return CONNMAN_POLICY_AUTO; | ||
1119 | - else if (g_str_equal(policy, "manual") == TRUE) | ||
1120 | - return CONNMAN_POLICY_MANUAL; | ||
1121 | - | ||
1122 | - return CONNMAN_POLICY_UNKNOWN; | ||
1123 | -} | ||
1124 | - | ||
1125 | -static guint get_security(const GValue *value) | ||
1126 | -{ | ||
1127 | - const char *security = value ? g_value_get_string(value) : NULL; | ||
1128 | - | ||
1129 | - if (security == NULL) | ||
1130 | - return CONNMAN_SECURITY_UNKNOWN; | ||
1131 | - else if (g_str_equal(security, "none") == TRUE) | ||
1132 | - return CONNMAN_SECURITY_NONE; | ||
1133 | - else if (g_str_equal(security, "wep") == TRUE) | ||
1134 | - return CONNMAN_SECURITY_WEP; | ||
1135 | - else if (g_str_equal(security, "wpa") == TRUE) | ||
1136 | - return CONNMAN_SECURITY_WPA; | ||
1137 | - else if (g_str_equal(security, "wpa2") == TRUE) | ||
1138 | - return CONNMAN_SECURITY_WPA2; | ||
1139 | - | ||
1140 | - return CONNMAN_SECURITY_UNKNOWN; | ||
1141 | -} | ||
1142 | - | ||
1143 | -static void network_changed(DBusGProxy *proxy, const char *property, | ||
1144 | - GValue *value, gpointer user_data) | ||
1145 | +static void enabled_technologies_changed(GtkTreeStore *store, GValue *value) | ||
1146 | { | ||
1147 | - GtkTreeStore *store = user_data; | ||
1148 | - const char *path = dbus_g_proxy_get_path(proxy); | ||
1149 | GtkTreeIter iter; | ||
1150 | + gboolean ethernet_enabled_prev, ethernet_enabled = FALSE; | ||
1151 | + gboolean wifi_enabled_prev, wifi_enabled = FALSE; | ||
1152 | + gchar **tech = g_value_get_boxed (value); | ||
1153 | + gint i; | ||
1154 | + gboolean ret; | ||
1155 | |||
1156 | - DBG("store %p proxy %p property %s", store, proxy, property); | ||
1157 | - | ||
1158 | - if (property == NULL || value == NULL) | ||
1159 | + if (value == NULL) | ||
1160 | return; | ||
1161 | |||
1162 | - if (get_iter_from_path(store, &iter, path) == FALSE) | ||
1163 | - return; | ||
1164 | + for (i = 0; i < g_strv_length (tech); i++) | ||
1165 | + { | ||
1166 | + if (g_str_equal("ethernet", *(tech + i))) | ||
1167 | + ethernet_enabled = TRUE; | ||
1168 | + else if (g_str_equal ("wifi", *(tech + i))) | ||
1169 | + wifi_enabled = TRUE; | ||
1170 | + } | ||
1171 | |||
1172 | - if (g_str_equal(property, "Connected") == TRUE) { | ||
1173 | - gboolean connected = g_value_get_boolean(value); | ||
1174 | - gtk_tree_store_set(store, &iter, | ||
1175 | - CONNMAN_COLUMN_ENABLED, connected, -1); | ||
1176 | - } else if (g_str_equal(property, "Available") == TRUE) { | ||
1177 | - gboolean inrange = g_value_get_boolean(value); | ||
1178 | - gtk_tree_store_set(store, &iter, | ||
1179 | - CONNMAN_COLUMN_INRANGE, inrange, -1); | ||
1180 | - } else if (g_str_equal(property, "Remember") == TRUE) { | ||
1181 | - gboolean remember = g_value_get_boolean(value); | ||
1182 | + get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_ETHERNET); | ||
1183 | + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, | ||
1184 | + CONNMAN_COLUMN_ETHERNET_ENABLED, ðernet_enabled_prev, -1); | ||
1185 | + if (ethernet_enabled_prev != ethernet_enabled) | ||
1186 | gtk_tree_store_set(store, &iter, | ||
1187 | - CONNMAN_COLUMN_REMEMBER, remember, -1); | ||
1188 | - } else if (g_str_equal(property, "Strength") == TRUE) { | ||
1189 | - guint strength = g_value_get_uchar(value); | ||
1190 | + CONNMAN_COLUMN_ETHERNET_ENABLED, ethernet_enabled, -1); | ||
1191 | + | ||
1192 | + ret = get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_WIFI); | ||
1193 | + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, | ||
1194 | + CONNMAN_COLUMN_WIFI_ENABLED, &wifi_enabled_prev, -1); | ||
1195 | + if (wifi_enabled_prev != wifi_enabled) | ||
1196 | gtk_tree_store_set(store, &iter, | ||
1197 | - CONNMAN_COLUMN_STRENGTH, strength, -1); | ||
1198 | - } | ||
1199 | + CONNMAN_COLUMN_WIFI_ENABLED, wifi_enabled, -1); | ||
1200 | } | ||
1201 | |||
1202 | -static void network_properties(DBusGProxy *proxy, GHashTable *hash, | ||
1203 | - GError *error, gpointer user_data) | ||
1204 | +static void enabled_technologies_properties(GtkTreeStore *store, DBusGProxy *proxy, GValue *value) | ||
1205 | { | ||
1206 | - GtkTreeStore *store = user_data; | ||
1207 | - GValue *value; | ||
1208 | - const gchar *device, *name, *secret; | ||
1209 | - gboolean connected, inrange, remember; | ||
1210 | - guint strength, security; | ||
1211 | - GtkTreeIter iter, parent; | ||
1212 | - | ||
1213 | - DBG("store %p proxy %p hash %p", store, proxy, hash); | ||
1214 | - | ||
1215 | - if (error != NULL || hash == NULL) | ||
1216 | - goto done; | ||
1217 | - | ||
1218 | - value = g_hash_table_lookup(hash, "Device"); | ||
1219 | - device = value ? g_value_get_boxed(value) : NULL; | ||
1220 | - | ||
1221 | - value = g_hash_table_lookup(hash, "Name"); | ||
1222 | - name = value ? g_value_get_string(value) : NULL; | ||
1223 | - | ||
1224 | - value = g_hash_table_lookup(hash, "Connected"); | ||
1225 | - connected = value ? g_value_get_boolean(value) : FALSE; | ||
1226 | - | ||
1227 | - value = g_hash_table_lookup(hash, "Available"); | ||
1228 | - inrange = value ? g_value_get_boolean(value) : FALSE; | ||
1229 | + GtkTreeIter iter; | ||
1230 | + gboolean ethernet_enabled = FALSE; | ||
1231 | + gboolean wifi_enabled = FALSE; | ||
1232 | + gchar **tech = g_value_get_boxed (value); | ||
1233 | + gint i; | ||
1234 | + | ||
1235 | + for (i = 0; i < g_strv_length (tech); i++) | ||
1236 | + { | ||
1237 | + if (g_str_equal("ethernet", *(tech + i))) | ||
1238 | + ethernet_enabled = TRUE; | ||
1239 | + else if (g_str_equal ("wifi", *(tech + i))) | ||
1240 | + wifi_enabled = TRUE; | ||
1241 | + } | ||
1242 | |||
1243 | - value = g_hash_table_lookup(hash, "Remember"); | ||
1244 | - remember = value ? g_value_get_boolean(value) : FALSE; | ||
1245 | + if (get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_ETHERNET) == FALSE) | ||
1246 | + gtk_tree_store_append(store, &iter, NULL); | ||
1247 | |||
1248 | - value = g_hash_table_lookup(hash, "Strength"); | ||
1249 | - strength = value ? g_value_get_uchar(value) : 0; | ||
1250 | + gtk_tree_store_set(store, &iter, | ||
1251 | + CONNMAN_COLUMN_PROXY, proxy, | ||
1252 | + CONNMAN_COLUMN_ETHERNET_ENABLED, ethernet_enabled, | ||
1253 | + CONNMAN_COLUMN_TYPE, CONNMAN_TYPE_LABEL_ETHERNET, | ||
1254 | + -1); | ||
1255 | |||
1256 | - value = g_hash_table_lookup(hash, "WiFi.Security"); | ||
1257 | - security = get_security(value); | ||
1258 | + if (get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_WIFI) == FALSE) | ||
1259 | + gtk_tree_store_append(store, &iter, NULL); | ||
1260 | |||
1261 | - value = g_hash_table_lookup(hash, "WiFi.Passphrase"); | ||
1262 | - secret = value ? g_value_get_string(value) : NULL; | ||
1263 | + gtk_tree_store_set(store, &iter, | ||
1264 | + CONNMAN_COLUMN_PROXY, proxy, | ||
1265 | + CONNMAN_COLUMN_WIFI_ENABLED, wifi_enabled, | ||
1266 | + CONNMAN_COLUMN_TYPE, CONNMAN_TYPE_LABEL_WIFI, | ||
1267 | + -1); | ||
1268 | +} | ||
1269 | |||
1270 | - DBG("name %s strength %d", name, strength); | ||
1271 | +static void offline_mode_changed(GtkTreeStore *store, GValue *value) | ||
1272 | +{ | ||
1273 | + GtkTreeIter iter; | ||
1274 | + gboolean offline_mode = g_value_get_boolean(value); | ||
1275 | |||
1276 | - if (get_iter_from_path(store, &parent, device) == FALSE) | ||
1277 | - return; | ||
1278 | + get_iter_from_type(store, &iter, CONNMAN_TYPE_SYSCONFIG); | ||
1279 | + gtk_tree_store_set(store, &iter, | ||
1280 | + CONNMAN_COLUMN_OFFLINEMODE, offline_mode, | ||
1281 | + -1); | ||
1282 | +} | ||
1283 | |||
1284 | - if (get_iter_from_proxy(store, &iter, proxy) == FALSE) { | ||
1285 | - gtk_tree_store_insert_with_values(store, &iter, &parent, -1, | ||
1286 | - CONNMAN_COLUMN_PROXY, proxy, | ||
1287 | - CONNMAN_COLUMN_NAME, name, | ||
1288 | - CONNMAN_COLUMN_ENABLED, connected, | ||
1289 | - CONNMAN_COLUMN_INRANGE, inrange, | ||
1290 | - CONNMAN_COLUMN_REMEMBER, remember, | ||
1291 | - CONNMAN_COLUMN_STRENGTH, strength, | ||
1292 | - CONNMAN_COLUMN_SECURITY, security, | ||
1293 | - CONNMAN_COLUMN_PASSPHRASE, secret, -1); | ||
1294 | +static void offline_mode_properties(GtkTreeStore *store, DBusGProxy *proxy, GValue *value) | ||
1295 | +{ | ||
1296 | + GtkTreeIter iter; | ||
1297 | + gboolean offline_mode = g_value_get_boolean(value); | ||
1298 | |||
1299 | - dbus_g_proxy_add_signal(proxy, "PropertyChanged", | ||
1300 | - G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); | ||
1301 | - dbus_g_proxy_connect_signal(proxy, "PropertyChanged", | ||
1302 | - G_CALLBACK(network_changed), store, NULL); | ||
1303 | - } else | ||
1304 | - gtk_tree_store_set(store, &iter, | ||
1305 | - CONNMAN_COLUMN_NAME, name, | ||
1306 | - CONNMAN_COLUMN_ENABLED, connected, | ||
1307 | - CONNMAN_COLUMN_INRANGE, inrange, | ||
1308 | - CONNMAN_COLUMN_REMEMBER, remember, | ||
1309 | - CONNMAN_COLUMN_STRENGTH, strength, | ||
1310 | - CONNMAN_COLUMN_SECURITY, security, | ||
1311 | - CONNMAN_COLUMN_PASSPHRASE, secret, -1); | ||
1312 | + if (get_iter_from_type(store, &iter, CONNMAN_TYPE_SYSCONFIG) == FALSE) | ||
1313 | + gtk_tree_store_insert(store, &iter, NULL, 0); | ||
1314 | |||
1315 | -done: | ||
1316 | - g_object_unref(proxy); | ||
1317 | + gtk_tree_store_set(store, &iter, | ||
1318 | + CONNMAN_COLUMN_PROXY, proxy, | ||
1319 | + CONNMAN_COLUMN_TYPE, CONNMAN_TYPE_SYSCONFIG, | ||
1320 | + CONNMAN_COLUMN_OFFLINEMODE, offline_mode, | ||
1321 | + -1); | ||
1322 | } | ||
1323 | |||
1324 | -static void device_changed(DBusGProxy *proxy, const char *property, | ||
1325 | +static void service_changed(DBusGProxy *proxy, const char *property, | ||
1326 | GValue *value, gpointer user_data) | ||
1327 | { | ||
1328 | GtkTreeStore *store = user_data; | ||
1329 | const char *path = dbus_g_proxy_get_path(proxy); | ||
1330 | GtkTreeIter iter; | ||
1331 | + GHashTable *ipv4; | ||
1332 | + const char *method, *addr, *netmask, *gateway; | ||
1333 | + GValue *ipv4_method, *ipv4_address, *ipv4_netmask, *ipv4_gateway; | ||
1334 | + | ||
1335 | + const char *state, *icon, *name, *security, *passphrase; | ||
1336 | + guint strength, type; | ||
1337 | + | ||
1338 | |||
1339 | DBG("store %p proxy %p property %s", store, proxy, property); | ||
1340 | |||
1341 | @@ -421,165 +384,167 @@ static void device_changed(DBusGProxy *proxy, const char *property, | ||
1342 | if (get_iter_from_path(store, &iter, path) == FALSE) | ||
1343 | return; | ||
1344 | |||
1345 | - if (g_str_equal(property, "Policy") == TRUE) { | ||
1346 | - guint policy = get_policy(value); | ||
1347 | - gtk_tree_store_set(store, &iter, | ||
1348 | - CONNMAN_COLUMN_POLICY, policy, -1); | ||
1349 | - } else if (g_str_equal(property, "Powered") == TRUE) { | ||
1350 | - gboolean powered = g_value_get_boolean(value); | ||
1351 | - gtk_tree_store_set(store, &iter, | ||
1352 | - CONNMAN_COLUMN_ENABLED, powered, -1); | ||
1353 | - } else if (g_str_equal(property, "Networks") == TRUE) | ||
1354 | - property_update(store, value, path, network_properties); | ||
1355 | -} | ||
1356 | - | ||
1357 | -static void device_properties(DBusGProxy *proxy, GHashTable *hash, | ||
1358 | - GError *error, gpointer user_data) | ||
1359 | -{ | ||
1360 | - GtkTreeStore *store = user_data; | ||
1361 | - const char *path = dbus_g_proxy_get_path(proxy); | ||
1362 | - GValue *value; | ||
1363 | - const gchar *name, *icon; | ||
1364 | - guint type, policy; | ||
1365 | - gboolean powered; | ||
1366 | - GtkTreeIter iter; | ||
1367 | - | ||
1368 | - DBG("store %p proxy %p hash %p", store, proxy, hash); | ||
1369 | + if (g_str_equal(property, "IPv4") == TRUE) { | ||
1370 | |||
1371 | - if (error != NULL || hash == NULL) | ||
1372 | - goto done; | ||
1373 | - | ||
1374 | - value = g_hash_table_lookup(hash, "Name"); | ||
1375 | - name = value ? g_value_get_string(value) : NULL; | ||
1376 | - | ||
1377 | - value = g_hash_table_lookup(hash, "Type"); | ||
1378 | - type = get_type(value); | ||
1379 | - icon = type2icon(type); | ||
1380 | + ipv4 = g_value_get_boxed (value); | ||
1381 | + if (!ipv4) | ||
1382 | + return; | ||
1383 | |||
1384 | - value = g_hash_table_lookup(hash, "Policy"); | ||
1385 | - policy = get_policy(value); | ||
1386 | + ipv4_method = g_hash_table_lookup (ipv4, "Method"); | ||
1387 | + method = ipv4_method ? g_value_get_string(ipv4_method) : NULL; | ||
1388 | |||
1389 | - value = g_hash_table_lookup(hash, "Powered"); | ||
1390 | - powered = value ? g_value_get_boolean(value) : FALSE; | ||
1391 | + ipv4_address = g_hash_table_lookup (ipv4, "Address"); | ||
1392 | + addr = ipv4_address ? g_value_get_string(ipv4_address) : NULL; | ||
1393 | |||
1394 | - DBG("name %s type %d icon %s", name, type, icon); | ||
1395 | + ipv4_netmask = g_hash_table_lookup (ipv4, "Netmask"); | ||
1396 | + netmask = ipv4_netmask ? g_value_get_string(ipv4_netmask) : NULL; | ||
1397 | |||
1398 | - if (get_iter_from_proxy(store, &iter, proxy) == FALSE) { | ||
1399 | - gtk_tree_store_insert_with_values(store, &iter, NULL, -1, | ||
1400 | - CONNMAN_COLUMN_PROXY, proxy, | ||
1401 | - CONNMAN_COLUMN_NAME, name, | ||
1402 | - CONNMAN_COLUMN_ICON, icon, | ||
1403 | - CONNMAN_COLUMN_TYPE, type, | ||
1404 | - CONNMAN_COLUMN_ENABLED, powered, | ||
1405 | - CONNMAN_COLUMN_POLICY, policy, -1); | ||
1406 | + ipv4_gateway = g_hash_table_lookup (ipv4, "Gateway"); | ||
1407 | + gateway = ipv4_gateway ? g_value_get_string(ipv4_gateway) : NULL; | ||
1408 | |||
1409 | - dbus_g_proxy_add_signal(proxy, "PropertyChanged", | ||
1410 | - G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); | ||
1411 | - dbus_g_proxy_connect_signal(proxy, "PropertyChanged", | ||
1412 | - G_CALLBACK(device_changed), store, NULL); | ||
1413 | - } else | ||
1414 | + gtk_tree_store_set(store, &iter, | ||
1415 | + CONNMAN_COLUMN_METHOD, method, | ||
1416 | + CONNMAN_COLUMN_ADDRESS, addr, | ||
1417 | + CONNMAN_COLUMN_NETMASK, netmask, | ||
1418 | + CONNMAN_COLUMN_GATEWAY, gateway, | ||
1419 | + -1); | ||
1420 | + | ||
1421 | + } else if (g_str_equal(property, "State") == TRUE) { | ||
1422 | + state = value ? g_value_get_string(value) : NULL; | ||
1423 | + gtk_tree_store_set(store, &iter, | ||
1424 | + CONNMAN_COLUMN_STATE, state, | ||
1425 | + -1); | ||
1426 | + } else if (g_str_equal(property, "Name") == TRUE) { | ||
1427 | + name = value ? g_value_get_string(value) : NULL; | ||
1428 | gtk_tree_store_set(store, &iter, | ||
1429 | CONNMAN_COLUMN_NAME, name, | ||
1430 | - CONNMAN_COLUMN_ICON, icon, | ||
1431 | + -1); | ||
1432 | + } else if (g_str_equal(property, "Type") == TRUE) { | ||
1433 | + type = get_type(value); | ||
1434 | + icon = type2icon(type); | ||
1435 | + gtk_tree_store_set(store, &iter, | ||
1436 | CONNMAN_COLUMN_TYPE, type, | ||
1437 | - CONNMAN_COLUMN_ENABLED, powered, | ||
1438 | - CONNMAN_COLUMN_POLICY, policy, -1); | ||
1439 | - | ||
1440 | - value = g_hash_table_lookup(hash, "Networks"); | ||
1441 | - if (value != NULL) | ||
1442 | - property_update(store, value, path, network_properties); | ||
1443 | - | ||
1444 | -done: | ||
1445 | - g_object_unref(proxy); | ||
1446 | -} | ||
1447 | - | ||
1448 | -static void connection_changed(DBusGProxy *proxy, const char *property, | ||
1449 | - GValue *value, gpointer user_data) | ||
1450 | -{ | ||
1451 | - GtkTreeStore *store = user_data; | ||
1452 | - const char *path = dbus_g_proxy_get_path(proxy); | ||
1453 | - GtkTreeIter iter; | ||
1454 | - | ||
1455 | - DBG("store %p proxy %p property %s", store, proxy, property); | ||
1456 | - | ||
1457 | - if (property == NULL || value == NULL) | ||
1458 | - return; | ||
1459 | - | ||
1460 | - if (get_iter_from_path(store, &iter, path) == FALSE) | ||
1461 | - return; | ||
1462 | - | ||
1463 | - if (g_str_equal(property, "Default") == TRUE) { | ||
1464 | - gboolean enabled = g_value_get_boolean(value); | ||
1465 | + CONNMAN_COLUMN_ICON, icon, | ||
1466 | + -1); | ||
1467 | + } else if (g_str_equal(property, "Security") == TRUE) { | ||
1468 | + security = value ? g_value_get_string(value) : NULL; | ||
1469 | + gtk_tree_store_set(store, &iter, | ||
1470 | + CONNMAN_COLUMN_SECURITY, security, | ||
1471 | + -1); | ||
1472 | + } else if (g_str_equal(property, "PassPhrase") == TRUE) { | ||
1473 | + passphrase = value ? g_value_get_string(value) : NULL; | ||
1474 | gtk_tree_store_set(store, &iter, | ||
1475 | - CONNMAN_COLUMN_ENABLED, enabled, -1); | ||
1476 | + CONNMAN_COLUMN_PASSPHRASE, passphrase, | ||
1477 | + -1); | ||
1478 | } else if (g_str_equal(property, "Strength") == TRUE) { | ||
1479 | - guint strength = g_value_get_uchar(value); | ||
1480 | + strength = value ? g_value_get_uchar(value) : 0; | ||
1481 | gtk_tree_store_set(store, &iter, | ||
1482 | - CONNMAN_COLUMN_STRENGTH, strength, -1); | ||
1483 | + CONNMAN_COLUMN_STRENGTH, strength, | ||
1484 | + -1); | ||
1485 | } | ||
1486 | } | ||
1487 | |||
1488 | -static void connection_properties(DBusGProxy *proxy, GHashTable *hash, | ||
1489 | +static void service_properties(DBusGProxy *proxy, GHashTable *hash, | ||
1490 | GError *error, gpointer user_data) | ||
1491 | { | ||
1492 | GtkTreeStore *store = user_data; | ||
1493 | - GValue *value; | ||
1494 | - guint type, strength; | ||
1495 | - gboolean enabled; | ||
1496 | - const char *device, *address; | ||
1497 | + | ||
1498 | + const char *state, *icon, *name, *security, *passphrase; | ||
1499 | + guint strength, type; | ||
1500 | + | ||
1501 | + GHashTable *ipv4; | ||
1502 | + GValue *ipv4_method, *ipv4_address, *ipv4_netmask, *ipv4_gateway; | ||
1503 | + const char *method, *addr, *netmask, *gateway; | ||
1504 | + | ||
1505 | GtkTreeIter iter; | ||
1506 | |||
1507 | + GValue *value; | ||
1508 | + | ||
1509 | DBG("store %p proxy %p hash %p", store, proxy, hash); | ||
1510 | |||
1511 | if (error != NULL || hash == NULL) | ||
1512 | goto done; | ||
1513 | |||
1514 | + value = g_hash_table_lookup(hash, "State"); | ||
1515 | + state = value ? g_value_get_string(value) : NULL; | ||
1516 | + | ||
1517 | + value = g_hash_table_lookup(hash, "Name"); | ||
1518 | + name = value ? g_value_get_string(value) : NULL; | ||
1519 | + | ||
1520 | value = g_hash_table_lookup(hash, "Type"); | ||
1521 | type = get_type(value); | ||
1522 | + icon = type2icon(type); | ||
1523 | + | ||
1524 | + value = g_hash_table_lookup(hash, "Security"); | ||
1525 | + security = value ? g_value_get_string(value) : NULL; | ||
1526 | + | ||
1527 | + value = g_hash_table_lookup(hash, "PassPhrase"); | ||
1528 | + passphrase = value ? g_value_get_string(value) : NULL; | ||
1529 | |||
1530 | value = g_hash_table_lookup(hash, "Strength"); | ||
1531 | strength = value ? g_value_get_uchar(value) : 0; | ||
1532 | |||
1533 | - value = g_hash_table_lookup(hash, "Default"); | ||
1534 | - enabled = value ? g_value_get_boolean(value) : FALSE; | ||
1535 | + value = g_hash_table_lookup(hash, "IPv4.Configuration"); | ||
1536 | + ipv4 = g_value_get_boxed (value); | ||
1537 | |||
1538 | - value = g_hash_table_lookup(hash, "IPv4.Address"); | ||
1539 | - address = value ? g_value_get_string(value) : NULL; | ||
1540 | + if (!ipv4) | ||
1541 | + goto done; | ||
1542 | |||
1543 | - DBG("type %d address %s", type, address); | ||
1544 | + ipv4_method = g_hash_table_lookup (ipv4, "Method"); | ||
1545 | + method = ipv4_method ? g_value_get_string(ipv4_method) : NULL; | ||
1546 | |||
1547 | - if (get_iter_from_proxy(store, &iter, proxy) == FALSE) { | ||
1548 | - gtk_tree_store_insert_with_values(store, &iter, NULL, -1, | ||
1549 | - CONNMAN_COLUMN_PROXY, proxy, | ||
1550 | - CONNMAN_COLUMN_TYPE, type, | ||
1551 | - CONNMAN_COLUMN_ENABLED, enabled, | ||
1552 | - CONNMAN_COLUMN_STRENGTH, strength, | ||
1553 | - CONNMAN_COLUMN_ADDRESS, address, -1); | ||
1554 | + ipv4_address = g_hash_table_lookup (ipv4, "Address"); | ||
1555 | + addr = ipv4_address ? g_value_get_string(ipv4_address) : NULL; | ||
1556 | |||
1557 | - dbus_g_proxy_add_signal(proxy, "PropertyChanged", | ||
1558 | - G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); | ||
1559 | - dbus_g_proxy_connect_signal(proxy, "PropertyChanged", | ||
1560 | - G_CALLBACK(connection_changed), store, NULL); | ||
1561 | - } else | ||
1562 | - gtk_tree_store_set(store, &iter, | ||
1563 | - CONNMAN_COLUMN_TYPE, type, | ||
1564 | - CONNMAN_COLUMN_ENABLED, enabled, | ||
1565 | - CONNMAN_COLUMN_STRENGTH, strength, -1); | ||
1566 | + ipv4_netmask = g_hash_table_lookup (ipv4, "Netmask"); | ||
1567 | + netmask = ipv4_netmask ? g_value_get_string(ipv4_netmask) : NULL; | ||
1568 | |||
1569 | - value = g_hash_table_lookup(hash, "Device"); | ||
1570 | - device = value ? g_value_get_boxed(value) : NULL; | ||
1571 | + ipv4_gateway = g_hash_table_lookup (ipv4, "Gateway"); | ||
1572 | + gateway = ipv4_gateway ? g_value_get_string(ipv4_gateway) : NULL; | ||
1573 | |||
1574 | - DBG("device %s", device); | ||
1575 | + DBG("name %s type %d icon %s state %s", name, type, icon, state); | ||
1576 | |||
1577 | - gtk_tree_store_set(store, &iter, CONNMAN_COLUMN_DEVICE, device, -1); | ||
1578 | + if (get_iter_from_proxy(store, &iter, proxy) == FALSE) { | ||
1579 | + GtkTreeIter label_iter; | ||
1580 | + guint label_type; | ||
1581 | |||
1582 | - if (get_iter_from_path(store, &iter, device) == TRUE) { | ||
1583 | - gtk_tree_store_set(store, &iter, | ||
1584 | - CONNMAN_COLUMN_DEVICE, device, | ||
1585 | - CONNMAN_COLUMN_INRANGE, TRUE, | ||
1586 | - CONNMAN_COLUMN_ADDRESS, address, -1); | ||
1587 | + switch (type) { | ||
1588 | + case CONNMAN_TYPE_ETHERNET: | ||
1589 | + label_type = CONNMAN_TYPE_LABEL_ETHERNET; | ||
1590 | + break; | ||
1591 | + case CONNMAN_TYPE_WIFI: | ||
1592 | + label_type = CONNMAN_TYPE_LABEL_WIFI; | ||
1593 | + break; | ||
1594 | + default: | ||
1595 | + label_type = CONNMAN_TYPE_UNKNOWN; | ||
1596 | + break; | ||
1597 | + } | ||
1598 | + | ||
1599 | + get_iter_from_type(store, &label_iter, label_type); | ||
1600 | + | ||
1601 | + gtk_tree_store_insert_after(store, &iter, NULL, &label_iter); | ||
1602 | + | ||
1603 | + dbus_g_proxy_add_signal(proxy, "PropertyChanged", | ||
1604 | + G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); | ||
1605 | + dbus_g_proxy_connect_signal(proxy, "PropertyChanged", | ||
1606 | + G_CALLBACK(service_changed), store, NULL); | ||
1607 | } | ||
1608 | |||
1609 | + gtk_tree_store_set(store, &iter, | ||
1610 | + CONNMAN_COLUMN_PROXY, proxy, | ||
1611 | + CONNMAN_COLUMN_NAME, name, | ||
1612 | + CONNMAN_COLUMN_ICON, icon, | ||
1613 | + CONNMAN_COLUMN_TYPE, type, | ||
1614 | + CONNMAN_COLUMN_STATE, state, | ||
1615 | + CONNMAN_COLUMN_SECURITY, security, | ||
1616 | + CONNMAN_COLUMN_PASSPHRASE, passphrase, | ||
1617 | + CONNMAN_COLUMN_STRENGTH, strength, | ||
1618 | + CONNMAN_COLUMN_METHOD, method, | ||
1619 | + CONNMAN_COLUMN_ADDRESS, addr, | ||
1620 | + CONNMAN_COLUMN_NETMASK, netmask, | ||
1621 | + CONNMAN_COLUMN_GATEWAY, gateway, | ||
1622 | + -1); | ||
1623 | + | ||
1624 | done: | ||
1625 | g_object_unref(proxy); | ||
1626 | } | ||
1627 | @@ -594,25 +559,12 @@ static void manager_changed(DBusGProxy *proxy, const char *property, | ||
1628 | if (property == NULL || value == NULL) | ||
1629 | return; | ||
1630 | |||
1631 | - if (g_str_equal(property, "State") == TRUE) { | ||
1632 | - ConnmanClientCallback callback; | ||
1633 | - gpointer userdata; | ||
1634 | - gchar *state; | ||
1635 | - | ||
1636 | - state = g_object_get_data(G_OBJECT(store), "State"); | ||
1637 | - g_free(state); | ||
1638 | - | ||
1639 | - state = g_value_dup_string(value); | ||
1640 | - g_object_set_data(G_OBJECT(store), "State", state); | ||
1641 | - | ||
1642 | - callback = g_object_get_data(G_OBJECT(store), "callback"); | ||
1643 | - userdata = g_object_get_data(G_OBJECT(store), "userdata"); | ||
1644 | - if (callback) | ||
1645 | - callback(state, userdata); | ||
1646 | - } else if (g_str_equal(property, "Connections") == TRUE) { | ||
1647 | - property_update(store, value, property, connection_properties); | ||
1648 | - } else if (g_str_equal(property, "Devices") == TRUE) { | ||
1649 | - property_update(store, value, property, device_properties); | ||
1650 | + if (g_str_equal(property, "Services") == TRUE) { | ||
1651 | + property_update(store, value, property, service_properties); | ||
1652 | + } else if (g_str_equal(property, "EnabledTechnologies") == TRUE) { | ||
1653 | + enabled_technologies_changed(store, value); | ||
1654 | + } else if (g_str_equal(property, "OfflineMode") == TRUE) { | ||
1655 | + offline_mode_changed(store, value); | ||
1656 | } | ||
1657 | } | ||
1658 | |||
1659 | @@ -620,31 +572,24 @@ static void manager_properties(DBusGProxy *proxy, GHashTable *hash, | ||
1660 | GError *error, gpointer user_data) | ||
1661 | { | ||
1662 | GtkTreeStore *store = user_data; | ||
1663 | - ConnmanClientCallback callback; | ||
1664 | GValue *value; | ||
1665 | - gchar *state; | ||
1666 | |||
1667 | DBG("store %p proxy %p hash %p", store, proxy, hash); | ||
1668 | |||
1669 | if (error != NULL || hash == NULL) | ||
1670 | return; | ||
1671 | |||
1672 | - value = g_hash_table_lookup(hash, "State"); | ||
1673 | - state = value ? g_value_dup_string(value) : NULL; | ||
1674 | - g_object_set_data(G_OBJECT(store), "State", state); | ||
1675 | - | ||
1676 | - callback = g_object_get_data(G_OBJECT(store), "callback"); | ||
1677 | - if (callback) | ||
1678 | - callback(state, NULL); | ||
1679 | + value = g_hash_table_lookup(hash, "Services"); | ||
1680 | + if (value != NULL) | ||
1681 | + property_update(store, value, "Services", service_properties); | ||
1682 | |||
1683 | - value = g_hash_table_lookup(hash, "Devices"); | ||
1684 | + value = g_hash_table_lookup(hash, "EnabledTechnologies"); | ||
1685 | if (value != NULL) | ||
1686 | - property_update(store, value, "Devices", device_properties); | ||
1687 | + enabled_technologies_properties(store, proxy, value); | ||
1688 | |||
1689 | - value = g_hash_table_lookup(hash, "Connections"); | ||
1690 | + value = g_hash_table_lookup(hash, "OfflineMode"); | ||
1691 | if (value != NULL) | ||
1692 | - property_update(store, value, | ||
1693 | - "Connections", connection_properties); | ||
1694 | + offline_mode_properties(store, proxy, value); | ||
1695 | } | ||
1696 | |||
1697 | DBusGProxy *connman_dbus_create_manager(DBusGConnection *conn, | ||
1698 | diff --git a/common/connman-dbus.h b/common/connman-dbus.h | ||
1699 | index a9fa51c..dc07650 100644 | ||
1700 | --- a/common/connman-dbus.h | ||
1701 | +++ b/common/connman-dbus.h | ||
1702 | @@ -31,7 +31,7 @@ | ||
1703 | #define CONNMAN_MANAGER_PATH "/" | ||
1704 | |||
1705 | #define CONNMAN_PROFILE_INTERFACE CONNMAN_SERVICE ".Profile" | ||
1706 | -#define CONNMAN_DEVICE_INTERFACE CONNMAN_SERVICE ".Device" | ||
1707 | +#define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service" | ||
1708 | #define CONNMAN_NETWORK_INTERFACE CONNMAN_SERVICE ".Network" | ||
1709 | #define CONNMAN_CONNECTION_INTERFACE CONNMAN_SERVICE ".Connection" | ||
1710 | |||
1711 | diff --git a/common/connman-dbus.xml b/common/connman-dbus.xml | ||
1712 | index 9fefd55..e20cb3b 100644 | ||
1713 | --- a/common/connman-dbus.xml | ||
1714 | +++ b/common/connman-dbus.xml | ||
1715 | @@ -15,5 +15,16 @@ | ||
1716 | </method> | ||
1717 | <method name="Disconnect"> | ||
1718 | </method> | ||
1719 | + <method name="Remove"> | ||
1720 | + </method> | ||
1721 | + <method name="RequestScan"> | ||
1722 | + <arg type="s"/> | ||
1723 | + </method> | ||
1724 | + <method name="EnableTechnology"> | ||
1725 | + <arg type="s"/> | ||
1726 | + </method> | ||
1727 | + <method name="DisableTechnology"> | ||
1728 | + <arg type="s"/> | ||
1729 | + </method> | ||
1730 | </interface> | ||
1731 | </node> | ||
1732 | diff --git a/common/demo.c b/common/demo.c | ||
1733 | deleted file mode 100644 | ||
1734 | index 5e3924f..0000000 | ||
1735 | --- a/common/demo.c | ||
1736 | +++ /dev/null | ||
1737 | @@ -1,465 +0,0 @@ | ||
1738 | -/* | ||
1739 | - * | ||
1740 | - * Connection Manager | ||
1741 | - * | ||
1742 | - * Copyright (C) 2008 Intel Corporation. All rights reserved. | ||
1743 | - * | ||
1744 | - * This program is free software; you can redistribute it and/or modify | ||
1745 | - * it under the terms of the GNU General Public License version 2 as | ||
1746 | - * published by the Free Software Foundation. | ||
1747 | - * | ||
1748 | - * This program is distributed in the hope that it will be useful, | ||
1749 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1750 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1751 | - * GNU General Public License for more details. | ||
1752 | - * | ||
1753 | - * You should have received a copy of the GNU General Public License | ||
1754 | - * along with this program; if not, write to the Free Software | ||
1755 | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
1756 | - * | ||
1757 | - */ | ||
1758 | - | ||
1759 | -#ifdef HAVE_CONFIG_H | ||
1760 | -#include <config.h> | ||
1761 | -#endif | ||
1762 | - | ||
1763 | -#include <dbus/dbus-glib.h> | ||
1764 | -#include <gtk/gtk.h> | ||
1765 | - | ||
1766 | -#include "connman-client.h" | ||
1767 | - | ||
1768 | -static gboolean option_fullscreen = FALSE; | ||
1769 | -static ConnmanClient *client; | ||
1770 | - | ||
1771 | -static GtkWidget *tree_networks = NULL; | ||
1772 | -static GtkWidget *button_enabled = NULL; | ||
1773 | -static GtkWidget *button_refresh = NULL; | ||
1774 | -static GtkWidget *button_connect = NULL; | ||
1775 | -static GtkWidget *label_status = NULL; | ||
1776 | -static GtkTreeSelection *selection = NULL; | ||
1777 | - | ||
1778 | -static void status_callback(const char *status, void *user_data) | ||
1779 | -{ | ||
1780 | - gchar *markup; | ||
1781 | - | ||
1782 | - if (label_status == NULL) | ||
1783 | - return; | ||
1784 | - | ||
1785 | - markup = g_strdup_printf("System is %s", status); | ||
1786 | - gtk_label_set_markup(GTK_LABEL(label_status), markup); | ||
1787 | - g_free(markup); | ||
1788 | -} | ||
1789 | - | ||
1790 | -static GtkWidget *create_label(const gchar *str) | ||
1791 | -{ | ||
1792 | - GtkWidget *label; | ||
1793 | - gchar *tmp; | ||
1794 | - | ||
1795 | - label = gtk_label_new(NULL); | ||
1796 | - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | ||
1797 | - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); | ||
1798 | - | ||
1799 | - tmp = g_strdup_printf("<b>%s</b>", str); | ||
1800 | - gtk_label_set_markup(GTK_LABEL(label), tmp); | ||
1801 | - g_free(tmp); | ||
1802 | - | ||
1803 | - return label; | ||
1804 | -} | ||
1805 | - | ||
1806 | -static void changed_callback(GtkComboBox *combo, gpointer user_data) | ||
1807 | -{ | ||
1808 | - GtkTreeModel *model = gtk_combo_box_get_model(combo); | ||
1809 | - GtkTreeIter iter; | ||
1810 | - DBusGProxy *proxy; | ||
1811 | - gchar *path; | ||
1812 | - gboolean enabled; | ||
1813 | - | ||
1814 | - if (gtk_combo_box_get_active_iter(combo, &iter) == FALSE) | ||
1815 | - return; | ||
1816 | - | ||
1817 | - path = g_object_get_data(G_OBJECT(button_enabled), "device"); | ||
1818 | - g_free(path); | ||
1819 | - | ||
1820 | - gtk_tree_model_get(model, &iter, CONNMAN_COLUMN_PROXY, &proxy, | ||
1821 | - CONNMAN_COLUMN_ENABLED, &enabled, -1); | ||
1822 | - | ||
1823 | - path = g_strdup(dbus_g_proxy_get_path(proxy)); | ||
1824 | - g_object_set_data(G_OBJECT(button_enabled), "device", path); | ||
1825 | - | ||
1826 | - g_object_unref(proxy); | ||
1827 | - | ||
1828 | - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_enabled), | ||
1829 | - enabled); | ||
1830 | - | ||
1831 | - gtk_widget_set_sensitive(button_refresh, enabled); | ||
1832 | - | ||
1833 | - model = connman_client_get_network_model(client, path); | ||
1834 | - gtk_tree_view_set_model(GTK_TREE_VIEW(tree_networks), model); | ||
1835 | - g_object_unref(model); | ||
1836 | -} | ||
1837 | - | ||
1838 | -static void toggled_callback(GtkToggleButton *button, gpointer user_data) | ||
1839 | -{ | ||
1840 | - gchar *path; | ||
1841 | - gboolean active; | ||
1842 | - | ||
1843 | - path = g_object_get_data(G_OBJECT(button), "device"); | ||
1844 | - if (path == NULL) | ||
1845 | - return; | ||
1846 | - | ||
1847 | - active = gtk_toggle_button_get_active(button); | ||
1848 | - | ||
1849 | - connman_client_set_powered(client, path, active); | ||
1850 | - | ||
1851 | - gtk_widget_set_sensitive(button_refresh, active); | ||
1852 | -} | ||
1853 | - | ||
1854 | -static void refresh_callback(GtkButton *button, gpointer user_data) | ||
1855 | -{ | ||
1856 | - gchar *path; | ||
1857 | - | ||
1858 | - path = g_object_get_data(G_OBJECT(button_enabled), "device"); | ||
1859 | - if (path == NULL) | ||
1860 | - return; | ||
1861 | - | ||
1862 | - connman_client_propose_scan(client, path); | ||
1863 | -} | ||
1864 | - | ||
1865 | -static void connect_callback(GtkButton *button, gpointer user_data) | ||
1866 | -{ | ||
1867 | - GtkTreeModel *model; | ||
1868 | - GtkTreeIter iter; | ||
1869 | - DBusGProxy *proxy; | ||
1870 | - const gchar *path; | ||
1871 | - gboolean enabled; | ||
1872 | - | ||
1873 | - if (gtk_tree_selection_get_selected(selection, &model, &iter) == FALSE) | ||
1874 | - return; | ||
1875 | - | ||
1876 | - gtk_tree_model_get(model, &iter, CONNMAN_COLUMN_PROXY, &proxy, | ||
1877 | - CONNMAN_COLUMN_ENABLED, &enabled, -1); | ||
1878 | - | ||
1879 | - path = dbus_g_proxy_get_path(proxy); | ||
1880 | - | ||
1881 | - if (enabled == FALSE) | ||
1882 | - connman_client_connect(client, path); | ||
1883 | - else | ||
1884 | - connman_client_disconnect(client, path); | ||
1885 | - | ||
1886 | - g_object_unref(proxy); | ||
1887 | - | ||
1888 | - if (enabled == FALSE) | ||
1889 | - g_object_set(button_connect, | ||
1890 | - "label", GTK_STOCK_DISCONNECT, NULL); | ||
1891 | - else | ||
1892 | - g_object_set(button_connect, | ||
1893 | - "label", GTK_STOCK_CONNECT, NULL); | ||
1894 | -} | ||
1895 | - | ||
1896 | -static GtkWidget *create_left(void) | ||
1897 | -{ | ||
1898 | - GtkWidget *mainbox; | ||
1899 | - GtkWidget *vbox; | ||
1900 | - GtkWidget *hbox; | ||
1901 | - GtkWidget *label; | ||
1902 | - GtkWidget *combo; | ||
1903 | - GtkWidget *button; | ||
1904 | - GtkTreeModel *model; | ||
1905 | - GtkCellRenderer *renderer; | ||
1906 | - | ||
1907 | - mainbox = gtk_vbox_new(FALSE, 24); | ||
1908 | - gtk_container_set_border_width(GTK_CONTAINER(mainbox), 8); | ||
1909 | - | ||
1910 | - vbox = gtk_vbox_new(FALSE, 6); | ||
1911 | - gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0); | ||
1912 | - | ||
1913 | - label = create_label("Device"); | ||
1914 | - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | ||
1915 | - | ||
1916 | - combo = gtk_combo_box_new(); | ||
1917 | - gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 0); | ||
1918 | - g_signal_connect(G_OBJECT(combo), "changed", | ||
1919 | - G_CALLBACK(changed_callback), NULL); | ||
1920 | - | ||
1921 | - gtk_cell_layout_clear(GTK_CELL_LAYOUT(combo)); | ||
1922 | - | ||
1923 | - renderer = gtk_cell_renderer_text_new(); | ||
1924 | - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE); | ||
1925 | - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, | ||
1926 | - "text", CONNMAN_COLUMN_NAME, NULL); | ||
1927 | - | ||
1928 | - button = gtk_check_button_new_with_label("Enabled"); | ||
1929 | - gtk_box_pack_end(GTK_BOX(vbox), button, FALSE, FALSE, 0); | ||
1930 | - g_signal_connect(G_OBJECT(button), "toggled", | ||
1931 | - G_CALLBACK(toggled_callback), NULL); | ||
1932 | - | ||
1933 | - button_enabled = button; | ||
1934 | - | ||
1935 | - vbox = gtk_vbox_new(FALSE, 6); | ||
1936 | - gtk_box_pack_start(GTK_BOX(mainbox), vbox, TRUE, TRUE, 0); | ||
1937 | - | ||
1938 | - label = create_label("Status"); | ||
1939 | - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | ||
1940 | - | ||
1941 | - label = gtk_label_new(NULL); | ||
1942 | - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | ||
1943 | - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); | ||
1944 | - gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); | ||
1945 | - | ||
1946 | - label_status = label; | ||
1947 | - | ||
1948 | - vbox = gtk_vbox_new(FALSE, 6); | ||
1949 | - gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0); | ||
1950 | - | ||
1951 | - hbox = gtk_hbox_new(FALSE, 12); | ||
1952 | - gtk_box_set_homogeneous(GTK_BOX(hbox), TRUE); | ||
1953 | - gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0); | ||
1954 | - | ||
1955 | - button = gtk_button_new_from_stock(GTK_STOCK_REFRESH); | ||
1956 | - gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); | ||
1957 | - gtk_widget_set_sensitive(button, FALSE); | ||
1958 | - g_signal_connect(G_OBJECT(button), "clicked", | ||
1959 | - G_CALLBACK(refresh_callback), NULL); | ||
1960 | - | ||
1961 | - button_refresh = button; | ||
1962 | - | ||
1963 | - button = gtk_button_new_from_stock(GTK_STOCK_DISCONNECT); | ||
1964 | - gtk_box_pack_end(GTK_BOX(hbox), button, TRUE, TRUE, 0); | ||
1965 | - gtk_widget_set_sensitive(button, FALSE); | ||
1966 | - g_signal_connect(G_OBJECT(button), "clicked", | ||
1967 | - G_CALLBACK(connect_callback), NULL); | ||
1968 | - | ||
1969 | - button_connect = button; | ||
1970 | - | ||
1971 | - model = connman_client_get_device_model(client); | ||
1972 | - gtk_combo_box_set_model(GTK_COMBO_BOX(combo), model); | ||
1973 | - g_object_unref(model); | ||
1974 | - | ||
1975 | - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); | ||
1976 | - | ||
1977 | - return mainbox; | ||
1978 | -} | ||
1979 | - | ||
1980 | -static void select_callback(GtkTreeSelection *selection, gpointer user_data) | ||
1981 | -{ | ||
1982 | - GtkTreeModel *model; | ||
1983 | - GtkTreeIter iter; | ||
1984 | - gboolean selected, enabled; | ||
1985 | - | ||
1986 | - selected = gtk_tree_selection_get_selected(selection, &model, &iter); | ||
1987 | - | ||
1988 | - if (selected == TRUE) { | ||
1989 | - gtk_tree_model_get(model, &iter, | ||
1990 | - CONNMAN_COLUMN_ENABLED, &enabled, -1); | ||
1991 | - | ||
1992 | - if (enabled == TRUE) | ||
1993 | - g_object_set(button_connect, | ||
1994 | - "label", GTK_STOCK_DISCONNECT, NULL); | ||
1995 | - else | ||
1996 | - g_object_set(button_connect, | ||
1997 | - "label", GTK_STOCK_CONNECT, NULL); | ||
1998 | - } | ||
1999 | - | ||
2000 | - gtk_widget_set_sensitive(button_connect, selected); | ||
2001 | -} | ||
2002 | - | ||
2003 | -static void status_to_icon(GtkTreeViewColumn *column, GtkCellRenderer *cell, | ||
2004 | - GtkTreeModel *model, GtkTreeIter *iter, gpointer data) | ||
2005 | -{ | ||
2006 | - gboolean enabled; | ||
2007 | - | ||
2008 | - gtk_tree_model_get(model, iter, CONNMAN_COLUMN_ENABLED, &enabled, -1); | ||
2009 | - | ||
2010 | - if (enabled == TRUE) | ||
2011 | - g_object_set(cell, "icon-name", GTK_STOCK_ABOUT, NULL); | ||
2012 | - | ||
2013 | - g_object_set(cell, "visible", enabled, NULL); | ||
2014 | -} | ||
2015 | - | ||
2016 | -static void security_to_icon(GtkTreeViewColumn *column, GtkCellRenderer *cell, | ||
2017 | - GtkTreeModel *model, GtkTreeIter *iter, gpointer data) | ||
2018 | -{ | ||
2019 | - guint security; | ||
2020 | - | ||
2021 | - gtk_tree_model_get(model, iter, CONNMAN_COLUMN_SECURITY, &security, -1); | ||
2022 | - | ||
2023 | - if (security == CONNMAN_SECURITY_NONE) | ||
2024 | - g_object_set(cell, "icon-name", NULL, NULL); | ||
2025 | - else | ||
2026 | - g_object_set(cell, "icon-name", | ||
2027 | - GTK_STOCK_DIALOG_AUTHENTICATION, NULL); | ||
2028 | -} | ||
2029 | - | ||
2030 | -static GtkWidget *create_right(void) | ||
2031 | -{ | ||
2032 | - GtkWidget *mainbox; | ||
2033 | - GtkWidget *vbox; | ||
2034 | - GtkWidget *label; | ||
2035 | - GtkWidget *scrolled; | ||
2036 | - GtkWidget *tree; | ||
2037 | - GtkTreeViewColumn *column; | ||
2038 | - GtkCellRenderer *renderer; | ||
2039 | - | ||
2040 | - mainbox = gtk_vbox_new(FALSE, 24); | ||
2041 | - gtk_container_set_border_width(GTK_CONTAINER(mainbox), 8); | ||
2042 | - | ||
2043 | - vbox = gtk_vbox_new(FALSE, 6); | ||
2044 | - gtk_box_pack_start(GTK_BOX(mainbox), vbox, TRUE, TRUE, 0); | ||
2045 | - | ||
2046 | - label = create_label("Networks"); | ||
2047 | - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | ||
2048 | - | ||
2049 | - scrolled = gtk_scrolled_window_new(NULL, NULL); | ||
2050 | - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), | ||
2051 | - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | ||
2052 | - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), | ||
2053 | - GTK_SHADOW_OUT); | ||
2054 | - gtk_container_add(GTK_CONTAINER(vbox), scrolled); | ||
2055 | - | ||
2056 | - tree = gtk_tree_view_new(); | ||
2057 | - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE); | ||
2058 | - gtk_tree_view_set_show_expanders(GTK_TREE_VIEW(tree), FALSE); | ||
2059 | - gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree), TRUE); | ||
2060 | - gtk_container_add(GTK_CONTAINER(scrolled), tree); | ||
2061 | - | ||
2062 | - gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(tree), 0, | ||
2063 | - NULL, gtk_cell_renderer_pixbuf_new(), | ||
2064 | - status_to_icon, NULL, NULL); | ||
2065 | - column = gtk_tree_view_get_column(GTK_TREE_VIEW(tree), 0); | ||
2066 | - gtk_tree_view_column_set_min_width(column, 24); | ||
2067 | - | ||
2068 | - column = gtk_tree_view_column_new(); | ||
2069 | - gtk_tree_view_column_set_expand(GTK_TREE_VIEW_COLUMN(column), TRUE); | ||
2070 | - gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); | ||
2071 | - | ||
2072 | - renderer = gtk_cell_renderer_text_new(); | ||
2073 | - gtk_tree_view_column_pack_start(column, renderer, TRUE); | ||
2074 | - gtk_tree_view_column_add_attribute(column, renderer, | ||
2075 | - "text", CONNMAN_COLUMN_NAME); | ||
2076 | - | ||
2077 | - renderer = gtk_cell_renderer_pixbuf_new(); | ||
2078 | - gtk_tree_view_column_pack_end(column, renderer, FALSE); | ||
2079 | - gtk_tree_view_column_set_cell_data_func(column, renderer, | ||
2080 | - security_to_icon, NULL, NULL); | ||
2081 | - | ||
2082 | - tree_networks = tree; | ||
2083 | - | ||
2084 | - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); | ||
2085 | - gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); | ||
2086 | - g_signal_connect(G_OBJECT(selection), "changed", | ||
2087 | - G_CALLBACK(select_callback), NULL); | ||
2088 | - | ||
2089 | - return mainbox; | ||
2090 | -} | ||
2091 | - | ||
2092 | -static gboolean delete_callback(GtkWidget *window, GdkEvent *event, | ||
2093 | - gpointer user_data) | ||
2094 | -{ | ||
2095 | - gtk_widget_destroy(window); | ||
2096 | - | ||
2097 | - gtk_main_quit(); | ||
2098 | - | ||
2099 | - return FALSE; | ||
2100 | -} | ||
2101 | - | ||
2102 | -static void close_callback(GtkWidget *button, gpointer user_data) | ||
2103 | -{ | ||
2104 | - GtkWidget *window = user_data; | ||
2105 | - | ||
2106 | - gtk_widget_destroy(window); | ||
2107 | - | ||
2108 | - gtk_main_quit(); | ||
2109 | -} | ||
2110 | - | ||
2111 | -static GtkWidget *create_window(void) | ||
2112 | -{ | ||
2113 | - GtkWidget *window; | ||
2114 | - GtkWidget *vbox; | ||
2115 | - GtkWidget *hbox; | ||
2116 | - GtkWidget *notebook; | ||
2117 | - GtkWidget *buttonbox; | ||
2118 | - GtkWidget *button; | ||
2119 | - GtkWidget *widget; | ||
2120 | - | ||
2121 | - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | ||
2122 | - gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); | ||
2123 | - gtk_window_set_default_size(GTK_WINDOW(window), 580, 360); | ||
2124 | - g_signal_connect(G_OBJECT(window), "delete-event", | ||
2125 | - G_CALLBACK(delete_callback), NULL); | ||
2126 | - | ||
2127 | - vbox = gtk_vbox_new(FALSE, 12); | ||
2128 | - gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); | ||
2129 | - gtk_container_add(GTK_CONTAINER(window), vbox); | ||
2130 | - | ||
2131 | - notebook = gtk_notebook_new(); | ||
2132 | - gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE); | ||
2133 | - gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); | ||
2134 | - | ||
2135 | - buttonbox = gtk_hbutton_box_new(); | ||
2136 | - gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonbox), GTK_BUTTONBOX_END); | ||
2137 | - gtk_box_pack_start(GTK_BOX(vbox), buttonbox, FALSE, FALSE, 0); | ||
2138 | - | ||
2139 | - button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | ||
2140 | - gtk_container_add(GTK_CONTAINER(buttonbox), button); | ||
2141 | - g_signal_connect(G_OBJECT(button), "clicked", | ||
2142 | - G_CALLBACK(close_callback), window); | ||
2143 | - | ||
2144 | - hbox = gtk_hbox_new(FALSE, 0); | ||
2145 | - gtk_container_set_border_width(GTK_CONTAINER(hbox), 8); | ||
2146 | - | ||
2147 | - widget = create_right(); | ||
2148 | - gtk_widget_set_size_request(widget, 280, -1); | ||
2149 | - gtk_box_pack_end(GTK_BOX(hbox), widget, TRUE, TRUE, 0); | ||
2150 | - | ||
2151 | - widget = create_left(); | ||
2152 | - gtk_widget_set_size_request(widget, 260, -1); | ||
2153 | - gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); | ||
2154 | - | ||
2155 | - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), hbox, NULL); | ||
2156 | - | ||
2157 | - return window; | ||
2158 | -} | ||
2159 | - | ||
2160 | -static GOptionEntry options[] = { | ||
2161 | - { "fullscreen", 'f', 0, G_OPTION_ARG_NONE, &option_fullscreen, | ||
2162 | - "Start up in fullscreen mode" }, | ||
2163 | - { NULL }, | ||
2164 | -}; | ||
2165 | - | ||
2166 | -int main(int argc, char *argv[]) | ||
2167 | -{ | ||
2168 | - GError *error = NULL; | ||
2169 | - GtkWidget *window; | ||
2170 | - | ||
2171 | - if (gtk_init_with_args(&argc, &argv, NULL, | ||
2172 | - options, NULL, &error) == FALSE) { | ||
2173 | - if (error != NULL) { | ||
2174 | - g_printerr("%s\n", error->message); | ||
2175 | - g_error_free(error); | ||
2176 | - } else | ||
2177 | - g_printerr("An unknown error occurred\n"); | ||
2178 | - | ||
2179 | - gtk_exit(1); | ||
2180 | - } | ||
2181 | - | ||
2182 | - g_set_application_name("Connection Manager Demo"); | ||
2183 | - | ||
2184 | - gtk_window_set_default_icon_name("network-wireless"); | ||
2185 | - | ||
2186 | - client = connman_client_new(); | ||
2187 | - | ||
2188 | - window = create_window(); | ||
2189 | - | ||
2190 | - connman_client_set_callback(client, status_callback, NULL); | ||
2191 | - | ||
2192 | - if (option_fullscreen == TRUE) | ||
2193 | - gtk_window_fullscreen(GTK_WINDOW(window)); | ||
2194 | - | ||
2195 | - gtk_widget_show_all(window); | ||
2196 | - | ||
2197 | - gtk_main(); | ||
2198 | - | ||
2199 | - g_object_unref(client); | ||
2200 | - | ||
2201 | - return 0; | ||
2202 | -} | ||
2203 | diff --git a/common/test-client.c b/common/test-client.c | ||
2204 | deleted file mode 100644 | ||
2205 | index a78823f..0000000 | ||
2206 | --- a/common/test-client.c | ||
2207 | +++ /dev/null | ||
2208 | @@ -1,227 +0,0 @@ | ||
2209 | -/* | ||
2210 | - * | ||
2211 | - * Connection Manager | ||
2212 | - * | ||
2213 | - * Copyright (C) 2008 Intel Corporation. All rights reserved. | ||
2214 | - * | ||
2215 | - * This program is free software; you can redistribute it and/or modify | ||
2216 | - * it under the terms of the GNU General Public License version 2 as | ||
2217 | - * published by the Free Software Foundation. | ||
2218 | - * | ||
2219 | - * This program is distributed in the hope that it will be useful, | ||
2220 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2221 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2222 | - * GNU General Public License for more details. | ||
2223 | - * | ||
2224 | - * You should have received a copy of the GNU General Public License | ||
2225 | - * along with this program; if not, write to the Free Software | ||
2226 | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
2227 | - * | ||
2228 | - */ | ||
2229 | - | ||
2230 | -#ifdef HAVE_CONFIG_H | ||
2231 | -#include <config.h> | ||
2232 | -#endif | ||
2233 | - | ||
2234 | -#include <dbus/dbus-glib.h> | ||
2235 | -#include <gtk/gtk.h> | ||
2236 | - | ||
2237 | -#include "connman-client.h" | ||
2238 | - | ||
2239 | -static ConnmanClient *client; | ||
2240 | - | ||
2241 | -static void proxy_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell, | ||
2242 | - GtkTreeModel *model, GtkTreeIter *iter, gpointer data) | ||
2243 | -{ | ||
2244 | - DBusGProxy *proxy; | ||
2245 | - gchar *markup; | ||
2246 | - | ||
2247 | - gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy, -1); | ||
2248 | - | ||
2249 | - markup = g_strdup_printf("<b>%s</b>\n" | ||
2250 | - "<span size=\"xx-small\">%s\n\n</span>", | ||
2251 | - dbus_g_proxy_get_interface(proxy), | ||
2252 | - dbus_g_proxy_get_path(proxy)); | ||
2253 | - g_object_set(cell, "markup", markup, NULL); | ||
2254 | - g_free(markup); | ||
2255 | - | ||
2256 | - g_object_unref(proxy); | ||
2257 | -} | ||
2258 | - | ||
2259 | -static void name_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell, | ||
2260 | - GtkTreeModel *model, GtkTreeIter *iter, gpointer data) | ||
2261 | -{ | ||
2262 | - gchar *name, *icon; | ||
2263 | - guint type; | ||
2264 | - gchar *markup; | ||
2265 | - | ||
2266 | - gtk_tree_model_get(model, iter, CONNMAN_COLUMN_NAME, &name, | ||
2267 | - CONNMAN_COLUMN_ICON, &icon, | ||
2268 | - CONNMAN_COLUMN_TYPE, &type, -1); | ||
2269 | - | ||
2270 | - markup = g_strdup_printf("Name: %s\nIcon: %s\nType: %d", | ||
2271 | - name, icon, type); | ||
2272 | - g_object_set(cell, "markup", markup, NULL); | ||
2273 | - g_free(markup); | ||
2274 | - | ||
2275 | - g_free(icon); | ||
2276 | - g_free(name); | ||
2277 | -} | ||
2278 | - | ||
2279 | -static void status_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell, | ||
2280 | - GtkTreeModel *model, GtkTreeIter *iter, gpointer data) | ||
2281 | -{ | ||
2282 | - gboolean enabled, inrange, remember; | ||
2283 | - gchar *markup; | ||
2284 | - | ||
2285 | - gtk_tree_model_get(model, iter, CONNMAN_COLUMN_ENABLED, &enabled, | ||
2286 | - CONNMAN_COLUMN_INRANGE, &inrange, | ||
2287 | - CONNMAN_COLUMN_REMEMBER, &remember, -1); | ||
2288 | - | ||
2289 | - markup = g_strdup_printf("Enabled: %d\n" | ||
2290 | - "InRange: %d\nRemember: %d", | ||
2291 | - enabled, inrange, remember); | ||
2292 | - g_object_set(cell, "markup", markup, NULL); | ||
2293 | - g_free(markup); | ||
2294 | -} | ||
2295 | - | ||
2296 | -static void network_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell, | ||
2297 | - GtkTreeModel *model, GtkTreeIter *iter, gpointer data) | ||
2298 | -{ | ||
2299 | - guint strength, security; | ||
2300 | - gchar *secret; | ||
2301 | - gchar *markup; | ||
2302 | - | ||
2303 | - gtk_tree_model_get(model, iter, CONNMAN_COLUMN_STRENGTH, &strength, | ||
2304 | - CONNMAN_COLUMN_SECURITY, &security, | ||
2305 | - CONNMAN_COLUMN_PASSPHRASE, &secret, -1); | ||
2306 | - | ||
2307 | - markup = g_strdup_printf("Strength: %d\nSecurity: %d\nSecret: %s", | ||
2308 | - strength, security, secret); | ||
2309 | - g_object_set(cell, "markup", markup, NULL); | ||
2310 | - g_free(markup); | ||
2311 | - | ||
2312 | - g_free(secret); | ||
2313 | -} | ||
2314 | - | ||
2315 | -static GtkWidget *create_tree(void) | ||
2316 | -{ | ||
2317 | - GtkWidget *tree; | ||
2318 | - GtkTreeModel *model; | ||
2319 | - GtkTreeSelection *selection; | ||
2320 | - | ||
2321 | - tree = gtk_tree_view_new(); | ||
2322 | - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), TRUE); | ||
2323 | - gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree), TRUE); | ||
2324 | - | ||
2325 | - gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(tree), -1, | ||
2326 | - "Proxy", gtk_cell_renderer_text_new(), | ||
2327 | - proxy_to_text, NULL, NULL); | ||
2328 | - | ||
2329 | - gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(tree), -1, | ||
2330 | - "Name", gtk_cell_renderer_text_new(), | ||
2331 | - name_to_text, NULL, NULL); | ||
2332 | - | ||
2333 | - gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(tree), -1, | ||
2334 | - "Status", gtk_cell_renderer_text_new(), | ||
2335 | - status_to_text, NULL, NULL); | ||
2336 | - | ||
2337 | - gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(tree), -1, | ||
2338 | - "Network", gtk_cell_renderer_text_new(), | ||
2339 | - network_to_text, NULL, NULL); | ||
2340 | - | ||
2341 | - model = connman_client_get_model(client); | ||
2342 | - gtk_tree_view_set_model(GTK_TREE_VIEW(tree), model); | ||
2343 | - g_object_unref(model); | ||
2344 | - | ||
2345 | - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); | ||
2346 | - gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); | ||
2347 | - | ||
2348 | - gtk_tree_view_expand_all(GTK_TREE_VIEW(tree)); | ||
2349 | - | ||
2350 | - return tree; | ||
2351 | -} | ||
2352 | - | ||
2353 | -static gboolean delete_callback(GtkWidget *window, GdkEvent *event, | ||
2354 | - gpointer user_data) | ||
2355 | -{ | ||
2356 | - gtk_widget_destroy(window); | ||
2357 | - | ||
2358 | - gtk_main_quit(); | ||
2359 | - | ||
2360 | - return FALSE; | ||
2361 | -} | ||
2362 | - | ||
2363 | -static void close_callback(GtkWidget *button, gpointer user_data) | ||
2364 | -{ | ||
2365 | - GtkWidget *window = user_data; | ||
2366 | - | ||
2367 | - gtk_widget_destroy(window); | ||
2368 | - | ||
2369 | - gtk_main_quit(); | ||
2370 | -} | ||
2371 | - | ||
2372 | -static GtkWidget *create_window(void) | ||
2373 | -{ | ||
2374 | - GtkWidget *window; | ||
2375 | - GtkWidget *mainbox; | ||
2376 | - GtkWidget *tree; | ||
2377 | - GtkWidget *scrolled; | ||
2378 | - GtkWidget *buttonbox; | ||
2379 | - GtkWidget *button; | ||
2380 | - GtkTreeSelection *selection; | ||
2381 | - | ||
2382 | - tree = create_tree(); | ||
2383 | - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); | ||
2384 | - | ||
2385 | - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | ||
2386 | - gtk_window_set_title(GTK_WINDOW(window), "Client Test"); | ||
2387 | - gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); | ||
2388 | - gtk_window_set_default_size(GTK_WINDOW(window), 800, 600); | ||
2389 | - g_signal_connect(G_OBJECT(window), "delete-event", | ||
2390 | - G_CALLBACK(delete_callback), NULL); | ||
2391 | - | ||
2392 | - mainbox = gtk_vbox_new(FALSE, 12); | ||
2393 | - gtk_container_set_border_width(GTK_CONTAINER(mainbox), 12); | ||
2394 | - gtk_container_add(GTK_CONTAINER(window), mainbox); | ||
2395 | - | ||
2396 | - scrolled = gtk_scrolled_window_new(NULL, NULL); | ||
2397 | - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), | ||
2398 | - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | ||
2399 | - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), | ||
2400 | - GTK_SHADOW_OUT); | ||
2401 | - gtk_box_pack_start(GTK_BOX(mainbox), scrolled, TRUE, TRUE, 0); | ||
2402 | - | ||
2403 | - buttonbox = gtk_hbutton_box_new(); | ||
2404 | - gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonbox), | ||
2405 | - GTK_BUTTONBOX_END); | ||
2406 | - gtk_box_pack_end(GTK_BOX(mainbox), buttonbox, FALSE, FALSE, 0); | ||
2407 | - | ||
2408 | - button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | ||
2409 | - gtk_container_add(GTK_CONTAINER(buttonbox), button); | ||
2410 | - g_signal_connect(G_OBJECT(button), "clicked", | ||
2411 | - G_CALLBACK(close_callback), window); | ||
2412 | - | ||
2413 | - gtk_container_add(GTK_CONTAINER(scrolled), tree); | ||
2414 | - | ||
2415 | - gtk_widget_show_all(window); | ||
2416 | - | ||
2417 | - return window; | ||
2418 | -} | ||
2419 | - | ||
2420 | -int main(int argc, char *argv[]) | ||
2421 | -{ | ||
2422 | - gtk_init(&argc, &argv); | ||
2423 | - | ||
2424 | - client = connman_client_new(); | ||
2425 | - | ||
2426 | - gtk_window_set_default_icon_name("network-wireless"); | ||
2427 | - | ||
2428 | - create_window(); | ||
2429 | - | ||
2430 | - gtk_main(); | ||
2431 | - | ||
2432 | - g_object_unref(client); | ||
2433 | - | ||
2434 | - return 0; | ||
2435 | -} | ||
2436 | diff --git a/properties/Makefile.am b/properties/Makefile.am | ||
2437 | index ad2fd35..3a47ccf 100644 | ||
2438 | --- a/properties/Makefile.am | ||
2439 | +++ b/properties/Makefile.am | ||
2440 | @@ -1,8 +1,7 @@ | ||
2441 | |||
2442 | bin_PROGRAMS = connman-properties | ||
2443 | |||
2444 | -connman_properties_SOURCES = main.c advanced.h advanced.c \ | ||
2445 | - ethernet.c wifi.c | ||
2446 | +connman_properties_SOURCES = main.c advanced.h ethernet.c wifi.c | ||
2447 | |||
2448 | connman_properties_LDADD = $(top_builddir)/common/libcommon.a \ | ||
2449 | @GTK_LIBS@ @DBUS_LIBS@ | ||
2450 | diff --git a/properties/advanced.c b/properties/advanced.c | ||
2451 | deleted file mode 100644 | ||
2452 | index 1eb1c3d..0000000 | ||
2453 | --- a/properties/advanced.c | ||
2454 | +++ /dev/null | ||
2455 | @@ -1,314 +0,0 @@ | ||
2456 | -/* | ||
2457 | - * | ||
2458 | - * Connection Manager | ||
2459 | - * | ||
2460 | - * Copyright (C) 2008 Intel Corporation. All rights reserved. | ||
2461 | - * | ||
2462 | - * This program is free software; you can redistribute it and/or modify | ||
2463 | - * it under the terms of the GNU General Public License version 2 as | ||
2464 | - * published by the Free Software Foundation. | ||
2465 | - * | ||
2466 | - * This program is distributed in the hope that it will be useful, | ||
2467 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2468 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2469 | - * GNU General Public License for more details. | ||
2470 | - * | ||
2471 | - * You should have received a copy of the GNU General Public License | ||
2472 | - * along with this program; if not, write to the Free Software | ||
2473 | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
2474 | - * | ||
2475 | - */ | ||
2476 | - | ||
2477 | -#ifdef HAVE_CONFIG_H | ||
2478 | -#include <config.h> | ||
2479 | -#endif | ||
2480 | - | ||
2481 | -#include <dbus/dbus-glib.h> | ||
2482 | -#include <glib/gi18n.h> | ||
2483 | - | ||
2484 | -#include "connman-client.h" | ||
2485 | - | ||
2486 | -#include "advanced.h" | ||
2487 | - | ||
2488 | -gboolean separator_function(GtkTreeModel *model, | ||
2489 | - GtkTreeIter *iter, gpointer user_data) | ||
2490 | -{ | ||
2491 | - gchar *text; | ||
2492 | - gboolean result = FALSE; | ||
2493 | - | ||
2494 | - gtk_tree_model_get(model, iter, 0, &text, -1); | ||
2495 | - | ||
2496 | - if (text && *text == '\0') | ||
2497 | - result = TRUE; | ||
2498 | - | ||
2499 | - g_free(text); | ||
2500 | - | ||
2501 | - return result; | ||
2502 | -} | ||
2503 | - | ||
2504 | -static void activate_callback(GtkWidget *button, gpointer user_data) | ||
2505 | -{ | ||
2506 | -} | ||
2507 | - | ||
2508 | -static void changed_callback(GtkWidget *editable, gpointer user_data) | ||
2509 | -{ | ||
2510 | -} | ||
2511 | - | ||
2512 | -static void add_network(GtkWidget *mainbox, struct config_data *data) | ||
2513 | -{ | ||
2514 | - GtkWidget *table; | ||
2515 | - GtkWidget *label; | ||
2516 | - GtkWidget *entry; | ||
2517 | - GtkWidget *combo; | ||
2518 | - GtkWidget *button; | ||
2519 | - | ||
2520 | - table = gtk_table_new(3, 5, TRUE); | ||
2521 | - gtk_table_set_row_spacings(GTK_TABLE(table), 2); | ||
2522 | - gtk_table_set_col_spacings(GTK_TABLE(table), 8); | ||
2523 | - gtk_box_pack_start(GTK_BOX(mainbox), table, FALSE, FALSE, 0); | ||
2524 | - | ||
2525 | - label = gtk_label_new(_("Network Name:")); | ||
2526 | - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); | ||
2527 | - gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); | ||
2528 | - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | ||
2529 | - | ||
2530 | - combo = gtk_combo_box_entry_new_text(); | ||
2531 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Guest"); | ||
2532 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), ""); | ||
2533 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Off"); | ||
2534 | - gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(combo), | ||
2535 | - separator_function, NULL, NULL); | ||
2536 | - gtk_table_attach_defaults(GTK_TABLE(table), combo, 1, 3, 0, 1); | ||
2537 | - //data->network.name = combo; | ||
2538 | - | ||
2539 | - label = gtk_label_new(_("Passphrase:")); | ||
2540 | - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); | ||
2541 | - gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); | ||
2542 | - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | ||
2543 | - | ||
2544 | - entry = gtk_entry_new(); | ||
2545 | - gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); | ||
2546 | - gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 3, 1, 2); | ||
2547 | - //data->network.passphrase = entry; | ||
2548 | - | ||
2549 | - button = gtk_button_new_with_label(_("Activate")); | ||
2550 | - gtk_widget_set_sensitive(button, FALSE); | ||
2551 | - gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 2, 3); | ||
2552 | - //data->network.activate = button; | ||
2553 | - | ||
2554 | - g_signal_connect(G_OBJECT(combo), "changed", | ||
2555 | - G_CALLBACK(changed_callback), data); | ||
2556 | - | ||
2557 | - g_signal_connect(G_OBJECT(button), "clicked", | ||
2558 | - G_CALLBACK(activate_callback), data); | ||
2559 | -} | ||
2560 | - | ||
2561 | -static void set_widgets(struct config_data *data, gboolean label, | ||
2562 | - gboolean value, gboolean entry) | ||
2563 | -{ | ||
2564 | - int i; | ||
2565 | - | ||
2566 | - for (i = 0; i < 3; i++) { | ||
2567 | - if (label == TRUE) | ||
2568 | - gtk_widget_show(data->ipv4.label[i]); | ||
2569 | - else | ||
2570 | - gtk_widget_hide(data->ipv4.label[i]); | ||
2571 | - | ||
2572 | - if (value == TRUE) | ||
2573 | - gtk_widget_show(data->ipv4.value[i]); | ||
2574 | - else | ||
2575 | - gtk_widget_hide(data->ipv4.value[i]); | ||
2576 | - | ||
2577 | - if (entry == TRUE) | ||
2578 | - gtk_widget_show(data->ipv4.entry[i]); | ||
2579 | - else | ||
2580 | - gtk_widget_hide(data->ipv4.entry[i]); | ||
2581 | - } | ||
2582 | -} | ||
2583 | - | ||
2584 | -static void config_callback(GtkWidget *widget, gpointer user_data) | ||
2585 | -{ | ||
2586 | - gint active; | ||
2587 | - | ||
2588 | - active = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); | ||
2589 | -} | ||
2590 | - | ||
2591 | -static void add_config(GtkWidget *mainbox, struct config_data *data) | ||
2592 | -{ | ||
2593 | - GtkWidget *table; | ||
2594 | - GtkWidget *label; | ||
2595 | - GtkWidget *entry; | ||
2596 | - GtkWidget *combo; | ||
2597 | - | ||
2598 | - table = gtk_table_new(5, 5, TRUE); | ||
2599 | - gtk_table_set_row_spacings(GTK_TABLE(table), 2); | ||
2600 | - gtk_table_set_col_spacings(GTK_TABLE(table), 8); | ||
2601 | - gtk_box_pack_start(GTK_BOX(mainbox), table, FALSE, FALSE, 0); | ||
2602 | - | ||
2603 | - label = gtk_label_new(_("Configure IPv4:")); | ||
2604 | - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); | ||
2605 | - gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); | ||
2606 | - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | ||
2607 | - | ||
2608 | - combo = gtk_combo_box_new_text(); | ||
2609 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Using DHCP"); | ||
2610 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Manually"); | ||
2611 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), ""); | ||
2612 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Off"); | ||
2613 | - gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(combo), | ||
2614 | - separator_function, NULL, NULL); | ||
2615 | - gtk_table_attach_defaults(GTK_TABLE(table), combo, 1, 3, 0, 1); | ||
2616 | - data->ipv4.config = combo; | ||
2617 | - | ||
2618 | - label = gtk_label_new(_("IP Address:")); | ||
2619 | - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); | ||
2620 | - gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); | ||
2621 | - gtk_widget_set_no_show_all(label, TRUE); | ||
2622 | - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | ||
2623 | - data->ipv4.label[0] = label; | ||
2624 | - | ||
2625 | - label = gtk_label_new(NULL); | ||
2626 | - gtk_label_set_selectable(GTK_LABEL(label), TRUE); | ||
2627 | - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | ||
2628 | - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | ||
2629 | - gtk_widget_set_no_show_all(label, TRUE); | ||
2630 | - gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 3, 1, 2); | ||
2631 | - data->ipv4.value[0] = label; | ||
2632 | - | ||
2633 | - entry = gtk_entry_new(); | ||
2634 | - gtk_widget_set_no_show_all(entry, TRUE); | ||
2635 | - gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 3, 1, 2); | ||
2636 | - data->ipv4.entry[0] = entry; | ||
2637 | - | ||
2638 | - label = gtk_label_new(_("Subnet Mask:")); | ||
2639 | - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); | ||
2640 | - gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); | ||
2641 | - gtk_widget_set_no_show_all(label, TRUE); | ||
2642 | - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); | ||
2643 | - data->ipv4.label[1] = label; | ||
2644 | - | ||
2645 | - label = gtk_label_new(NULL); | ||
2646 | - gtk_label_set_selectable(GTK_LABEL(label), TRUE); | ||
2647 | - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | ||
2648 | - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | ||
2649 | - gtk_widget_set_no_show_all(label, TRUE); | ||
2650 | - gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 3, 2, 3); | ||
2651 | - data->ipv4.value[1] = label; | ||
2652 | - | ||
2653 | - entry = gtk_entry_new(); | ||
2654 | - gtk_widget_set_no_show_all(entry, TRUE); | ||
2655 | - gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 3, 2, 3); | ||
2656 | - data->ipv4.entry[1] = entry; | ||
2657 | - | ||
2658 | - label = gtk_label_new(_("Router:")); | ||
2659 | - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); | ||
2660 | - gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); | ||
2661 | - gtk_widget_set_no_show_all(label, TRUE); | ||
2662 | - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); | ||
2663 | - data->ipv4.label[2] = label; | ||
2664 | - | ||
2665 | - label = gtk_label_new(NULL); | ||
2666 | - gtk_label_set_selectable(GTK_LABEL(label), TRUE); | ||
2667 | - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | ||
2668 | - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | ||
2669 | - gtk_widget_set_no_show_all(label, TRUE); | ||
2670 | - gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 3, 3, 4); | ||
2671 | - data->ipv4.value[2] = label; | ||
2672 | - | ||
2673 | - entry = gtk_entry_new(); | ||
2674 | - gtk_widget_set_no_show_all(entry, TRUE); | ||
2675 | - gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 3, 3, 4); | ||
2676 | - data->ipv4.entry[2] = entry; | ||
2677 | - | ||
2678 | - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); | ||
2679 | - set_widgets(data, TRUE, TRUE, FALSE); | ||
2680 | - | ||
2681 | - g_signal_connect(G_OBJECT(combo), "changed", | ||
2682 | - G_CALLBACK(config_callback), data); | ||
2683 | -} | ||
2684 | - | ||
2685 | -static void delete_callback(GtkWidget *window, GdkEvent *event, | ||
2686 | - gpointer user_data) | ||
2687 | -{ | ||
2688 | - gtk_widget_hide(window); | ||
2689 | -} | ||
2690 | - | ||
2691 | -static void close_callback(GtkWidget *button, gpointer user_data) | ||
2692 | -{ | ||
2693 | - GtkWidget *window = user_data; | ||
2694 | - | ||
2695 | - gtk_widget_hide(window); | ||
2696 | -} | ||
2697 | - | ||
2698 | -void create_advanced_dialog(struct config_data *data, guint type) | ||
2699 | -{ | ||
2700 | - GtkWidget *dialog; | ||
2701 | - GtkWidget *vbox; | ||
2702 | - GtkWidget *notebook; | ||
2703 | - GtkWidget *buttonbox; | ||
2704 | - GtkWidget *button; | ||
2705 | - GtkWidget *widget; | ||
2706 | - | ||
2707 | - dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); | ||
2708 | - gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); | ||
2709 | - gtk_window_set_transient_for(GTK_WINDOW(dialog), | ||
2710 | - GTK_WINDOW(data->window)); | ||
2711 | - gtk_window_set_title(GTK_WINDOW(dialog), _("Advanced Settings")); | ||
2712 | - gtk_window_set_position(GTK_WINDOW(dialog), | ||
2713 | - GTK_WIN_POS_CENTER_ON_PARENT); | ||
2714 | - gtk_window_set_default_size(GTK_WINDOW(dialog), 460, 320); | ||
2715 | - g_signal_connect(G_OBJECT(dialog), "delete-event", | ||
2716 | - G_CALLBACK(delete_callback), NULL); | ||
2717 | - | ||
2718 | - vbox = gtk_vbox_new(FALSE, 12); | ||
2719 | - gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); | ||
2720 | - gtk_container_add(GTK_CONTAINER(dialog), vbox); | ||
2721 | - | ||
2722 | - notebook = gtk_notebook_new(); | ||
2723 | - gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); | ||
2724 | - | ||
2725 | - buttonbox = gtk_hbutton_box_new(); | ||
2726 | - gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonbox), GTK_BUTTONBOX_END); | ||
2727 | - gtk_box_set_spacing(GTK_BOX(buttonbox), 6); | ||
2728 | - gtk_box_pack_start(GTK_BOX(vbox), buttonbox, FALSE, FALSE, 0); | ||
2729 | - | ||
2730 | - button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | ||
2731 | - gtk_container_add(GTK_CONTAINER(buttonbox), button); | ||
2732 | - g_signal_connect(G_OBJECT(button), "clicked", | ||
2733 | - G_CALLBACK(close_callback), dialog); | ||
2734 | - | ||
2735 | - button = gtk_button_new_from_stock(GTK_STOCK_OK); | ||
2736 | - gtk_container_add(GTK_CONTAINER(buttonbox), button); | ||
2737 | - g_signal_connect(G_OBJECT(button), "clicked", | ||
2738 | - G_CALLBACK(close_callback), dialog); | ||
2739 | - | ||
2740 | - if (type == CONNMAN_TYPE_WIFI) { | ||
2741 | - widget = gtk_vbox_new(FALSE, 24); | ||
2742 | - gtk_container_set_border_width(GTK_CONTAINER(widget), 24); | ||
2743 | - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, NULL); | ||
2744 | - gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(notebook), | ||
2745 | - widget, _("Wireless")); | ||
2746 | - add_network(widget, data); | ||
2747 | - } | ||
2748 | - | ||
2749 | - widget = gtk_vbox_new(FALSE, 24); | ||
2750 | - gtk_container_set_border_width(GTK_CONTAINER(widget), 24); | ||
2751 | - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, NULL); | ||
2752 | - gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(notebook), | ||
2753 | - widget, _("TCP/IP")); | ||
2754 | - add_config(widget, data); | ||
2755 | - | ||
2756 | - widget = gtk_label_new(NULL); | ||
2757 | - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, NULL); | ||
2758 | - gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(notebook), | ||
2759 | - widget, _("DNS")); | ||
2760 | - | ||
2761 | - if (type == CONNMAN_TYPE_ETHERNET) { | ||
2762 | - widget = gtk_label_new(NULL); | ||
2763 | - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, NULL); | ||
2764 | - gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(notebook), | ||
2765 | - widget, _("Ethernet")); | ||
2766 | - } | ||
2767 | - | ||
2768 | - data->dialog = dialog; | ||
2769 | -} | ||
2770 | diff --git a/properties/advanced.h b/properties/advanced.h | ||
2771 | index f85f10d..42b439f 100644 | ||
2772 | --- a/properties/advanced.h | ||
2773 | +++ b/properties/advanced.h | ||
2774 | @@ -23,6 +23,7 @@ struct config_data { | ||
2775 | ConnmanClient *client; | ||
2776 | |||
2777 | GtkWidget *widget; | ||
2778 | + GtkWidget *table; | ||
2779 | GtkWidget *title; | ||
2780 | GtkWidget *label; | ||
2781 | GtkWidget *button; | ||
2782 | @@ -45,15 +46,34 @@ struct config_data { | ||
2783 | GtkWidget *value[3]; | ||
2784 | GtkWidget *entry[3]; | ||
2785 | } ipv4; | ||
2786 | -}; | ||
2787 | |||
2788 | -void create_advanced_dialog(struct config_data *data, guint type); | ||
2789 | + struct ipv4_config ipv4_config; | ||
2790 | + | ||
2791 | + struct { | ||
2792 | + GtkWidget *name; | ||
2793 | + GtkWidget *security; | ||
2794 | + GtkWidget *strength; | ||
2795 | + GtkWidget *passphrase; | ||
2796 | + GtkWidget *connect_info; | ||
2797 | + GtkWidget *connect; | ||
2798 | + GtkWidget *disconnect; | ||
2799 | + } wifi; | ||
2800 | |||
2801 | -void add_ethernet_policy(GtkWidget *mainbox, struct config_data *data); | ||
2802 | -void update_ethernet_policy(struct config_data *data, guint policy); | ||
2803 | + GtkWidget *ethernet_button; | ||
2804 | + GtkWidget *wifi_button; | ||
2805 | |||
2806 | -void add_wifi_policy(GtkWidget *mainbox, struct config_data *data); | ||
2807 | + GtkWidget *scan_button; | ||
2808 | + GtkWidget *offline_button; | ||
2809 | +}; | ||
2810 | + | ||
2811 | +void add_ethernet_policy(GtkWidget *mainbox, GtkTreeIter *iter, struct config_data *data); | ||
2812 | +void update_ethernet_ipv4(struct config_data *data, guint policy); | ||
2813 | + | ||
2814 | +void add_wifi_policy(GtkWidget *mainbox, GtkTreeIter *iter, struct config_data *data); | ||
2815 | void update_wifi_policy(struct config_data *data, guint policy); | ||
2816 | |||
2817 | -gboolean separator_function(GtkTreeModel *model, | ||
2818 | - GtkTreeIter *iter, gpointer user_data); | ||
2819 | +void add_ethernet_switch_button(GtkWidget *mainbox, GtkTreeIter *iter, | ||
2820 | + struct config_data *data); | ||
2821 | + | ||
2822 | +void add_wifi_switch_button(GtkWidget *mainbox, GtkTreeIter *iter, | ||
2823 | + struct config_data *data); | ||
2824 | diff --git a/properties/ethernet.c b/properties/ethernet.c | ||
2825 | index d5c948d..d443ca1 100644 | ||
2826 | --- a/properties/ethernet.c | ||
2827 | +++ b/properties/ethernet.c | ||
2828 | @@ -23,6 +23,7 @@ | ||
2829 | #include <config.h> | ||
2830 | #endif | ||
2831 | |||
2832 | +#include <dbus/dbus-glib.h> | ||
2833 | #include <glib/gi18n.h> | ||
2834 | #include <gtk/gtk.h> | ||
2835 | |||
2836 | @@ -30,93 +31,220 @@ | ||
2837 | |||
2838 | #include "advanced.h" | ||
2839 | |||
2840 | +static gboolean separator_function(GtkTreeModel *model, | ||
2841 | + GtkTreeIter *iter, gpointer user_data) | ||
2842 | +{ | ||
2843 | + gchar *text; | ||
2844 | + gboolean result = FALSE; | ||
2845 | + | ||
2846 | + gtk_tree_model_get(model, iter, 0, &text, -1); | ||
2847 | + | ||
2848 | + if (text && *text == '\0') | ||
2849 | + result = TRUE; | ||
2850 | + | ||
2851 | + g_free(text); | ||
2852 | + | ||
2853 | + return result; | ||
2854 | +} | ||
2855 | + | ||
2856 | static void changed_callback(GtkWidget *editable, gpointer user_data) | ||
2857 | { | ||
2858 | struct config_data *data = user_data; | ||
2859 | gint active; | ||
2860 | |||
2861 | active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->policy.config)); | ||
2862 | + update_ethernet_ipv4(data, active); | ||
2863 | +} | ||
2864 | |||
2865 | - switch (active) { | ||
2866 | - case 0: | ||
2867 | - connman_client_set_policy(data->client, data->device, "auto"); | ||
2868 | - update_ethernet_policy(data, CONNMAN_POLICY_AUTO); | ||
2869 | - break; | ||
2870 | - case 1: | ||
2871 | - connman_client_set_policy(data->client, data->device, "ignore"); | ||
2872 | - update_ethernet_policy(data, CONNMAN_POLICY_IGNORE); | ||
2873 | - break; | ||
2874 | - case 3: | ||
2875 | - connman_client_set_policy(data->client, data->device, "off"); | ||
2876 | - update_ethernet_policy(data, CONNMAN_POLICY_OFF); | ||
2877 | - break; | ||
2878 | - } | ||
2879 | +static void apply_callback(GtkWidget *editable, gpointer user_data) | ||
2880 | +{ | ||
2881 | + struct config_data *data = user_data; | ||
2882 | + gint active; | ||
2883 | + | ||
2884 | + active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->policy.config)); | ||
2885 | + data->ipv4_config.method = active ? "manual" : "dhcp"; | ||
2886 | + data->ipv4_config.address = active ? gtk_entry_get_text(GTK_ENTRY(data->ipv4.entry[0])) : NULL; | ||
2887 | + data->ipv4_config.netmask = active ? gtk_entry_get_text(GTK_ENTRY(data->ipv4.entry[1])) : NULL; | ||
2888 | + data->ipv4_config.gateway = active ? gtk_entry_get_text(GTK_ENTRY(data->ipv4.entry[2])) : NULL; | ||
2889 | + | ||
2890 | + connman_client_set_ipv4(data->client, data->device, &data->ipv4_config); | ||
2891 | +} | ||
2892 | + | ||
2893 | +static void switch_callback(GtkWidget *editable, gpointer user_data) | ||
2894 | +{ | ||
2895 | + struct config_data *data = user_data; | ||
2896 | + const gchar *label = gtk_button_get_label(GTK_BUTTON(data->ethernet_button)); | ||
2897 | + if (g_str_equal(label, "Disable")) | ||
2898 | + connman_client_disable_technology(data->client, data->device, "ethernet"); | ||
2899 | + else if (g_str_equal(label, "Enable")) | ||
2900 | + connman_client_enable_technology(data->client, data->device, "ethernet"); | ||
2901 | } | ||
2902 | |||
2903 | -void add_ethernet_policy(GtkWidget *mainbox, struct config_data *data) | ||
2904 | +void add_ethernet_switch_button(GtkWidget *mainbox, GtkTreeIter *iter, | ||
2905 | + struct config_data *data) | ||
2906 | +{ | ||
2907 | + GtkWidget *vbox; | ||
2908 | + GtkWidget *table; | ||
2909 | + GtkWidget *label; | ||
2910 | + GtkWidget *buttonbox; | ||
2911 | + GtkWidget *button; | ||
2912 | + gboolean ethernet_enabled; | ||
2913 | + | ||
2914 | + gtk_tree_model_get(data->model, iter, | ||
2915 | + CONNMAN_COLUMN_ETHERNET_ENABLED, ðernet_enabled, | ||
2916 | + -1); | ||
2917 | + | ||
2918 | + vbox = gtk_vbox_new(TRUE, 0); | ||
2919 | + gtk_container_set_border_width(GTK_CONTAINER(vbox), 24); | ||
2920 | + gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0); | ||
2921 | + | ||
2922 | + table = gtk_table_new(1, 1, TRUE); | ||
2923 | + gtk_table_set_row_spacings(GTK_TABLE(table), 10); | ||
2924 | + gtk_table_set_col_spacings(GTK_TABLE(table), 10); | ||
2925 | + gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | ||
2926 | + | ||
2927 | + label = gtk_label_new(_("Enable/Disable Wired Networks.")); | ||
2928 | + gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | ||
2929 | + | ||
2930 | + buttonbox = gtk_hbutton_box_new(); | ||
2931 | + gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonbox), GTK_BUTTONBOX_CENTER); | ||
2932 | + gtk_box_pack_start(GTK_BOX(mainbox), buttonbox, FALSE, FALSE, 0); | ||
2933 | + | ||
2934 | + button = gtk_button_new(); | ||
2935 | + data->ethernet_button = button; | ||
2936 | + | ||
2937 | + if (ethernet_enabled) | ||
2938 | + gtk_button_set_label(GTK_BUTTON(button), _("Disable")); | ||
2939 | + else | ||
2940 | + gtk_button_set_label(GTK_BUTTON(button), _("Enable")); | ||
2941 | + | ||
2942 | + gtk_container_add(GTK_CONTAINER(buttonbox), button); | ||
2943 | + g_signal_connect(G_OBJECT(button), "clicked", | ||
2944 | + G_CALLBACK(switch_callback), data); | ||
2945 | +} | ||
2946 | + | ||
2947 | +void add_ethernet_policy(GtkWidget *mainbox, GtkTreeIter *iter, struct config_data *data) | ||
2948 | { | ||
2949 | GtkWidget *vbox; | ||
2950 | GtkWidget *table; | ||
2951 | GtkWidget *label; | ||
2952 | GtkWidget *combo; | ||
2953 | + GtkWidget *entry; | ||
2954 | + GtkWidget *button; | ||
2955 | + | ||
2956 | + struct ipv4_config ipv4_config = { | ||
2957 | + .method = NULL, | ||
2958 | + .address = NULL, | ||
2959 | + .netmask = NULL, | ||
2960 | + .gateway = NULL, | ||
2961 | + }; | ||
2962 | + | ||
2963 | + gtk_tree_model_get(data->model, iter, | ||
2964 | + CONNMAN_COLUMN_METHOD, &ipv4_config.method, | ||
2965 | + CONNMAN_COLUMN_ADDRESS, &ipv4_config.address, | ||
2966 | + CONNMAN_COLUMN_NETMASK, &ipv4_config.netmask, | ||
2967 | + CONNMAN_COLUMN_GATEWAY, &ipv4_config.gateway, | ||
2968 | + -1); | ||
2969 | |||
2970 | - vbox = gtk_vbox_new(FALSE, 0); | ||
2971 | + vbox = gtk_vbox_new(TRUE, 0); | ||
2972 | gtk_container_set_border_width(GTK_CONTAINER(vbox), 24); | ||
2973 | gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0); | ||
2974 | |||
2975 | - table = gtk_table_new(2, 4, FALSE); | ||
2976 | - gtk_table_set_row_spacings(GTK_TABLE(table), 8); | ||
2977 | - gtk_table_set_col_spacings(GTK_TABLE(table), 8); | ||
2978 | + table = gtk_table_new(5, 5, TRUE); | ||
2979 | + gtk_table_set_row_spacings(GTK_TABLE(table), 10); | ||
2980 | + gtk_table_set_col_spacings(GTK_TABLE(table), 10); | ||
2981 | gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | ||
2982 | |||
2983 | label = gtk_label_new(_("Configuration:")); | ||
2984 | - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); | ||
2985 | - gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); | ||
2986 | - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | ||
2987 | + gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1); | ||
2988 | |||
2989 | combo = gtk_combo_box_new_text(); | ||
2990 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Automatically"); | ||
2991 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Ignore Interface"); | ||
2992 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), ""); | ||
2993 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Off"); | ||
2994 | + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "DHCP"); | ||
2995 | + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Manual"); | ||
2996 | gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(combo), | ||
2997 | - separator_function, NULL, NULL); | ||
2998 | - gtk_table_attach_defaults(GTK_TABLE(table), combo, 1, 4, 0, 1); | ||
2999 | + separator_function, NULL, NULL); | ||
3000 | + | ||
3001 | + gtk_table_attach_defaults(GTK_TABLE(table), combo, 2, 4, 0, 1); | ||
3002 | data->policy.config = combo; | ||
3003 | |||
3004 | - label = gtk_label_new(NULL); | ||
3005 | - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | ||
3006 | - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | ||
3007 | - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); | ||
3008 | - gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 4, 1, 2); | ||
3009 | - gtk_widget_set_size_request(label, 180, -1); | ||
3010 | - data->policy.label = label; | ||
3011 | + label = gtk_label_new(_("IP address:")); | ||
3012 | + gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); | ||
3013 | + data->ipv4.label[0] = label; | ||
3014 | + | ||
3015 | + entry = gtk_entry_new(); | ||
3016 | + gtk_entry_set_max_length (GTK_ENTRY (entry), 15); | ||
3017 | + if (ipv4_config.address) | ||
3018 | + gtk_entry_set_text(GTK_ENTRY(entry), ipv4_config.address); | ||
3019 | + gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 4, 1, 2); | ||
3020 | + data->ipv4.entry[0] = entry; | ||
3021 | + | ||
3022 | + label = gtk_label_new(_("Netmask:")); | ||
3023 | + gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3); | ||
3024 | + data->ipv4.label[1] = label; | ||
3025 | + | ||
3026 | + entry = gtk_entry_new(); | ||
3027 | + gtk_entry_set_max_length (GTK_ENTRY (entry), 15); | ||
3028 | + if (ipv4_config.netmask) | ||
3029 | + gtk_entry_set_text(GTK_ENTRY(entry), ipv4_config.netmask); | ||
3030 | + gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 4, 2, 3); | ||
3031 | + data->ipv4.entry[1] = entry; | ||
3032 | + | ||
3033 | + label = gtk_label_new(_("Gateway:")); | ||
3034 | + gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 3, 4); | ||
3035 | + data->ipv4.label[2] = label; | ||
3036 | + | ||
3037 | + entry = gtk_entry_new(); | ||
3038 | + gtk_entry_set_max_length (GTK_ENTRY (entry), 15); | ||
3039 | + if (ipv4_config.gateway) | ||
3040 | + gtk_entry_set_text(GTK_ENTRY(entry), ipv4_config.gateway); | ||
3041 | + gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 4, 3, 4); | ||
3042 | + data->ipv4.entry[2] = entry; | ||
3043 | + | ||
3044 | + data->ipv4_config = ipv4_config; | ||
3045 | + | ||
3046 | + button = gtk_button_new_with_label(_("Apply")); | ||
3047 | + gtk_table_attach_defaults(GTK_TABLE(table), button, 3, 4, 4, 5); | ||
3048 | + g_signal_connect(G_OBJECT(button), "clicked", | ||
3049 | + G_CALLBACK(apply_callback), data); | ||
3050 | + | ||
3051 | + data->button = button; | ||
3052 | + | ||
3053 | + if (g_str_equal(ipv4_config.method, "dhcp") == TRUE) | ||
3054 | + update_ethernet_ipv4(data, CONNMAN_POLICY_DHCP); | ||
3055 | + else | ||
3056 | + update_ethernet_ipv4(data, CONNMAN_POLICY_MANUAL); | ||
3057 | |||
3058 | g_signal_connect(G_OBJECT(combo), "changed", | ||
3059 | - G_CALLBACK(changed_callback), data); | ||
3060 | + G_CALLBACK(changed_callback), data); | ||
3061 | } | ||
3062 | |||
3063 | -void update_ethernet_policy(struct config_data *data, guint policy) | ||
3064 | +void update_ethernet_ipv4(struct config_data *data, guint policy) | ||
3065 | { | ||
3066 | GtkWidget *combo = data->policy.config; | ||
3067 | - gchar *info = NULL; | ||
3068 | + GtkWidget *entry[3]; | ||
3069 | + int i; | ||
3070 | + | ||
3071 | + for (i = 0; i < 3; i++) | ||
3072 | + entry[i] = data->ipv4.entry[i]; | ||
3073 | |||
3074 | g_signal_handlers_block_by_func(G_OBJECT(combo), | ||
3075 | - G_CALLBACK(changed_callback), data); | ||
3076 | + G_CALLBACK(changed_callback), data); | ||
3077 | |||
3078 | switch (policy) { | ||
3079 | - case CONNMAN_POLICY_OFF: | ||
3080 | - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 3); | ||
3081 | + case CONNMAN_POLICY_DHCP: | ||
3082 | + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); | ||
3083 | + for (i = 0; i < 3; i++) { | ||
3084 | + gtk_entry_set_editable(GTK_ENTRY(entry[i]), 0); | ||
3085 | + gtk_widget_set_sensitive(entry[i], 0); | ||
3086 | + gtk_entry_set_text(GTK_ENTRY(entry[i]), _("")); | ||
3087 | + } | ||
3088 | break; | ||
3089 | - case CONNMAN_POLICY_IGNORE: | ||
3090 | + case CONNMAN_POLICY_MANUAL: | ||
3091 | gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 1); | ||
3092 | - info = g_strdup_printf(_("Ignore the interface and don't " | ||
3093 | - "make any attempts for configuration.")); | ||
3094 | - break; | ||
3095 | - case CONNMAN_POLICY_AUTO: | ||
3096 | - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); | ||
3097 | - info = g_strdup_printf(_("Detect carrier and then " | ||
3098 | - "automatically configure the interface.")); | ||
3099 | + for (i = 0; i < 3; i++) { | ||
3100 | + gtk_entry_set_editable(GTK_ENTRY(entry[i]), 1); | ||
3101 | + gtk_widget_set_sensitive(entry[i], 1); | ||
3102 | + } | ||
3103 | break; | ||
3104 | default: | ||
3105 | gtk_combo_box_set_active(GTK_COMBO_BOX(combo), -1); | ||
3106 | @@ -124,9 +252,5 @@ void update_ethernet_policy(struct config_data *data, guint policy) | ||
3107 | } | ||
3108 | |||
3109 | g_signal_handlers_unblock_by_func(G_OBJECT(combo), | ||
3110 | - G_CALLBACK(changed_callback), data); | ||
3111 | - | ||
3112 | - gtk_label_set_markup(GTK_LABEL(data->policy.label), info); | ||
3113 | - | ||
3114 | - g_free(info); | ||
3115 | + G_CALLBACK(changed_callback), data); | ||
3116 | } | ||
3117 | diff --git a/properties/main.c b/properties/main.c | ||
3118 | index 01439e6..6b389bc 100644 | ||
3119 | --- a/properties/main.c | ||
3120 | +++ b/properties/main.c | ||
3121 | @@ -32,103 +32,139 @@ | ||
3122 | |||
3123 | static ConnmanClient *client; | ||
3124 | static GtkWidget *interface_notebook; | ||
3125 | +static struct config_data *current_data; | ||
3126 | |||
3127 | -static void update_status(struct config_data *data, | ||
3128 | - guint type, gboolean inrange, guint policy, | ||
3129 | - const gchar *network, const gchar *address) | ||
3130 | +static void status_update(GtkTreeModel *model, GtkTreePath *path, | ||
3131 | + GtkTreeIter *iter, gpointer user_data) | ||
3132 | { | ||
3133 | - const char *str; | ||
3134 | - gchar *markup, *info = NULL; | ||
3135 | |||
3136 | - switch (type) { | ||
3137 | - case CONNMAN_TYPE_ETHERNET: | ||
3138 | - if (inrange == TRUE) { | ||
3139 | - str = N_("Connected"); | ||
3140 | - info = g_strdup_printf(_("%s is currently active " | ||
3141 | - "and has the IP address %s."), | ||
3142 | - N_("Ethernet"), address); | ||
3143 | - } else { | ||
3144 | - str = N_("Cable Unplugged"); | ||
3145 | - info = g_strdup_printf(_("The cable for %s is " | ||
3146 | - "not plugged in."), N_("Ethernet")); | ||
3147 | - } | ||
3148 | - break; | ||
3149 | + struct config_data *data = user_data; | ||
3150 | + guint type; | ||
3151 | + const char *name = NULL, *_name = NULL, *state = NULL; | ||
3152 | + gboolean ethernet_enabled; | ||
3153 | + gboolean wifi_enabled; | ||
3154 | + gboolean offline_mode; | ||
3155 | |||
3156 | - case CONNMAN_TYPE_WIFI: | ||
3157 | - if (inrange == TRUE) { | ||
3158 | - str = N_("Connected"); | ||
3159 | - info = g_strdup_printf(_("%s is currently active " | ||
3160 | - "and has the IP address %s."), | ||
3161 | - N_("Wireless"), address); | ||
3162 | - } else | ||
3163 | - str = N_("Not Connected"); | ||
3164 | - break; | ||
3165 | + gtk_tree_model_get(model, iter, | ||
3166 | + CONNMAN_COLUMN_STATE, &state, | ||
3167 | + CONNMAN_COLUMN_NAME, &name, | ||
3168 | + CONNMAN_COLUMN_TYPE, &type, | ||
3169 | + CONNMAN_COLUMN_ETHERNET_ENABLED, ðernet_enabled, | ||
3170 | + CONNMAN_COLUMN_WIFI_ENABLED, &wifi_enabled, | ||
3171 | + CONNMAN_COLUMN_OFFLINEMODE, &offline_mode, | ||
3172 | + -1); | ||
3173 | + | ||
3174 | + if (type == CONNMAN_TYPE_WIFI) { | ||
3175 | + if (data->wifi.name) | ||
3176 | + _name = gtk_label_get_text(GTK_LABEL(data->wifi.name)); | ||
3177 | + | ||
3178 | + if (!(name && _name && g_str_equal(name, _name))) | ||
3179 | + return; | ||
3180 | |||
3181 | - default: | ||
3182 | - if (inrange == TRUE) | ||
3183 | - str = N_("Connected"); | ||
3184 | + if (g_str_equal(state, "failure") == TRUE) { | ||
3185 | + gtk_label_set_text(GTK_LABEL(data->wifi.connect_info), | ||
3186 | + _("connection failed")); | ||
3187 | + gtk_widget_show(data->wifi.connect_info); | ||
3188 | + gtk_widget_show(data->wifi.connect); | ||
3189 | + gtk_widget_hide(data->wifi.disconnect); | ||
3190 | + } else if (g_str_equal(state, "idle") == TRUE) { | ||
3191 | + gtk_widget_hide(data->wifi.connect_info); | ||
3192 | + gtk_widget_show(data->wifi.connect); | ||
3193 | + gtk_widget_hide(data->wifi.disconnect); | ||
3194 | + } else { | ||
3195 | + gtk_widget_hide(data->wifi.connect_info); | ||
3196 | + gtk_widget_hide(data->wifi.connect); | ||
3197 | + gtk_widget_show(data->wifi.disconnect); | ||
3198 | + } | ||
3199 | + } else if (type == CONNMAN_TYPE_LABEL_ETHERNET) { | ||
3200 | + if (!data->ethernet_button) | ||
3201 | + return; | ||
3202 | + if (ethernet_enabled) | ||
3203 | + gtk_button_set_label(GTK_BUTTON(data->ethernet_button), _("Disable")); | ||
3204 | else | ||
3205 | - str = N_("Not Connected"); | ||
3206 | - break; | ||
3207 | + gtk_button_set_label(GTK_BUTTON(data->ethernet_button), _("Enable")); | ||
3208 | + } else if (type == CONNMAN_TYPE_LABEL_WIFI) { | ||
3209 | + if (!data->wifi_button) | ||
3210 | + return; | ||
3211 | + if (wifi_enabled) { | ||
3212 | + gtk_button_set_label(GTK_BUTTON(data->wifi_button), _("Disable")); | ||
3213 | + gtk_widget_set_sensitive(data->scan_button, 1); | ||
3214 | + } else { | ||
3215 | + gtk_button_set_label(GTK_BUTTON(data->wifi_button), _("Enable")); | ||
3216 | + gtk_widget_set_sensitive(data->scan_button, 0); | ||
3217 | + } | ||
3218 | + } else if (type == CONNMAN_TYPE_SYSCONFIG) { | ||
3219 | + if (!data->offline_button) | ||
3220 | + return; | ||
3221 | + if (offline_mode) | ||
3222 | + gtk_button_set_label(GTK_BUTTON(data->offline_button), _("OnlineMode")); | ||
3223 | + else | ||
3224 | + gtk_button_set_label(GTK_BUTTON(data->offline_button), _("OfflineMode")); | ||
3225 | } | ||
3226 | +} | ||
3227 | |||
3228 | - markup = g_strdup_printf("<b>%s</b>", str); | ||
3229 | - gtk_label_set_markup(GTK_LABEL(data->title), markup); | ||
3230 | - g_free(markup); | ||
3231 | - | ||
3232 | - gtk_label_set_markup(GTK_LABEL(data->label), info); | ||
3233 | - | ||
3234 | - g_free(info); | ||
3235 | - | ||
3236 | - switch (type) { | ||
3237 | - case CONNMAN_TYPE_ETHERNET: | ||
3238 | - update_ethernet_policy(data, policy); | ||
3239 | - break; | ||
3240 | - case CONNMAN_TYPE_WIFI: | ||
3241 | - update_wifi_policy(data, policy); | ||
3242 | - break; | ||
3243 | - default: | ||
3244 | - break; | ||
3245 | - } | ||
3246 | +static void set_offline_callback(GtkWidget *button, gpointer user_data) | ||
3247 | +{ | ||
3248 | + struct config_data *data = user_data; | ||
3249 | + const gchar *label = gtk_button_get_label(GTK_BUTTON(data->offline_button)); | ||
3250 | + if (g_str_equal(label, "OnlineMode")) | ||
3251 | + connman_client_set_offlinemode(client, 0); | ||
3252 | + else if (g_str_equal(label, "OfflineMode")) | ||
3253 | + connman_client_set_offlinemode(client, 1); | ||
3254 | } | ||
3255 | |||
3256 | -static void update_config(struct config_data *data) | ||
3257 | +static void add_system_config(GtkWidget *mainbox, GtkTreeIter *iter, | ||
3258 | + struct config_data *data) | ||
3259 | { | ||
3260 | - GtkTreeIter iter; | ||
3261 | - guint type; | ||
3262 | - gchar *network; | ||
3263 | + GtkWidget *vbox; | ||
3264 | + GtkWidget *table; | ||
3265 | + GtkWidget *label; | ||
3266 | + GtkWidget *buttonbox; | ||
3267 | + GtkWidget *button; | ||
3268 | + gboolean offline_mode; | ||
3269 | |||
3270 | - if (gtk_tree_model_get_iter_from_string(data->model, | ||
3271 | - &iter, data->index) == FALSE) | ||
3272 | - return; | ||
3273 | + vbox = gtk_vbox_new(TRUE, 0); | ||
3274 | + gtk_container_set_border_width(GTK_CONTAINER(vbox), 24); | ||
3275 | + gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0); | ||
3276 | |||
3277 | - gtk_tree_model_get(data->model, &iter, | ||
3278 | - CONNMAN_COLUMN_TYPE, &type, | ||
3279 | - CONNMAN_COLUMN_NAME, &network, -1); | ||
3280 | + table = gtk_table_new(1, 1, TRUE); | ||
3281 | + gtk_table_set_row_spacings(GTK_TABLE(table), 10); | ||
3282 | + gtk_table_set_col_spacings(GTK_TABLE(table), 10); | ||
3283 | + gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | ||
3284 | |||
3285 | - g_free(network); | ||
3286 | -} | ||
3287 | + label = gtk_label_new(_("System Configuration")); | ||
3288 | + gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | ||
3289 | |||
3290 | -static void advanced_callback(GtkWidget *button, gpointer user_data) | ||
3291 | -{ | ||
3292 | - struct config_data *data = user_data; | ||
3293 | + buttonbox = gtk_hbutton_box_new(); | ||
3294 | + gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonbox), GTK_BUTTONBOX_CENTER); | ||
3295 | + gtk_box_pack_start(GTK_BOX(mainbox), buttonbox, FALSE, FALSE, 0); | ||
3296 | + | ||
3297 | + gtk_tree_model_get(data->model, iter, | ||
3298 | + CONNMAN_COLUMN_OFFLINEMODE, &offline_mode, | ||
3299 | + -1); | ||
3300 | + | ||
3301 | + button = gtk_button_new(); | ||
3302 | + data->offline_button = button; | ||
3303 | + if (offline_mode) | ||
3304 | + gtk_button_set_label(GTK_BUTTON(button), _("OnlineMode")); | ||
3305 | + else | ||
3306 | + gtk_button_set_label(GTK_BUTTON(button), _("OfflineMode")); | ||
3307 | |||
3308 | - gtk_widget_show_all(data->dialog); | ||
3309 | + gtk_container_add(GTK_CONTAINER(buttonbox), button); | ||
3310 | + g_signal_connect(G_OBJECT(button), "clicked", | ||
3311 | + G_CALLBACK(set_offline_callback), data); | ||
3312 | } | ||
3313 | |||
3314 | static struct config_data *create_config(GtkTreeModel *model, | ||
3315 | - GtkTreeIter *iter, gpointer user_data) | ||
3316 | + GtkTreeIter *iter, gpointer user_data) | ||
3317 | { | ||
3318 | GtkWidget *mainbox; | ||
3319 | GtkWidget *label; | ||
3320 | GtkWidget *hbox; | ||
3321 | - GtkWidget *button; | ||
3322 | struct config_data *data; | ||
3323 | DBusGProxy *proxy; | ||
3324 | - guint type, policy; | ||
3325 | - gboolean inrange; | ||
3326 | - gchar *markup, *vendor = NULL, *product = NULL; | ||
3327 | - gchar *network = NULL, *address = NULL; | ||
3328 | + guint type; | ||
3329 | + char *state = NULL; | ||
3330 | |||
3331 | data = g_try_new0(struct config_data, 1); | ||
3332 | if (data == NULL) | ||
3333 | @@ -137,15 +173,10 @@ static struct config_data *create_config(GtkTreeModel *model, | ||
3334 | data->client = client; | ||
3335 | |||
3336 | gtk_tree_model_get(model, iter, | ||
3337 | - CONNMAN_COLUMN_PROXY, &proxy, | ||
3338 | - CONNMAN_COLUMN_TYPE, &type, | ||
3339 | - CONNMAN_COLUMN_INRANGE, &inrange, | ||
3340 | - CONNMAN_COLUMN_NETWORK, &network, | ||
3341 | - CONNMAN_COLUMN_ADDRESS, &address, | ||
3342 | - CONNMAN_COLUMN_POLICY, &policy, -1); | ||
3343 | - | ||
3344 | - data->device = g_strdup(dbus_g_proxy_get_path(proxy)); | ||
3345 | - g_object_unref(proxy); | ||
3346 | + CONNMAN_COLUMN_PROXY, &proxy, | ||
3347 | + CONNMAN_COLUMN_TYPE, &type, | ||
3348 | + CONNMAN_COLUMN_STATE, &state, | ||
3349 | + -1); | ||
3350 | |||
3351 | mainbox = gtk_vbox_new(FALSE, 6); | ||
3352 | data->widget = mainbox; | ||
3353 | @@ -163,12 +194,27 @@ static struct config_data *create_config(GtkTreeModel *model, | ||
3354 | gtk_box_pack_start(GTK_BOX(mainbox), label, FALSE, FALSE, 0); | ||
3355 | data->label = label; | ||
3356 | |||
3357 | + data->window = user_data; | ||
3358 | + data->model = model; | ||
3359 | + data->index = gtk_tree_model_get_string_from_iter(model, iter); | ||
3360 | + data->device = g_strdup(dbus_g_proxy_get_path(proxy)); | ||
3361 | + g_object_unref(proxy); | ||
3362 | + | ||
3363 | switch (type) { | ||
3364 | case CONNMAN_TYPE_ETHERNET: | ||
3365 | - add_ethernet_policy(mainbox, data); | ||
3366 | + add_ethernet_policy(mainbox, iter, data); | ||
3367 | break; | ||
3368 | case CONNMAN_TYPE_WIFI: | ||
3369 | - add_wifi_policy(mainbox, data); | ||
3370 | + add_wifi_policy(mainbox, iter, data); | ||
3371 | + break; | ||
3372 | + case CONNMAN_TYPE_LABEL_ETHERNET: | ||
3373 | + add_ethernet_switch_button(mainbox, iter, data); | ||
3374 | + break; | ||
3375 | + case CONNMAN_TYPE_LABEL_WIFI: | ||
3376 | + add_wifi_switch_button(mainbox, iter, data); | ||
3377 | + break; | ||
3378 | + case CONNMAN_TYPE_SYSCONFIG: | ||
3379 | + add_system_config(mainbox, iter, data); | ||
3380 | break; | ||
3381 | default: | ||
3382 | break; | ||
3383 | @@ -183,34 +229,10 @@ static struct config_data *create_config(GtkTreeModel *model, | ||
3384 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 1.0); | ||
3385 | gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); | ||
3386 | |||
3387 | - markup = g_strdup_printf("%s\n<small>%s</small>", | ||
3388 | - vendor ? vendor : "", product ? product : ""); | ||
3389 | - gtk_label_set_markup(GTK_LABEL(label), markup); | ||
3390 | - g_free(markup); | ||
3391 | - | ||
3392 | - if (0) { | ||
3393 | - button = gtk_button_new_with_label(_("Advanced...")); | ||
3394 | - gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | ||
3395 | - g_signal_connect(G_OBJECT(button), "clicked", | ||
3396 | - G_CALLBACK(advanced_callback), data); | ||
3397 | - data->button = button; | ||
3398 | - } | ||
3399 | - | ||
3400 | - data->window = user_data; | ||
3401 | - create_advanced_dialog(data, type); | ||
3402 | - | ||
3403 | - update_status(data, type, inrange, policy, network, address); | ||
3404 | - | ||
3405 | - g_free(network); | ||
3406 | - g_free(address); | ||
3407 | - | ||
3408 | - data->model = model; | ||
3409 | - data->index = gtk_tree_model_get_string_from_iter(model, iter); | ||
3410 | - | ||
3411 | gtk_widget_show_all(mainbox); | ||
3412 | |||
3413 | - g_free(product); | ||
3414 | - g_free(vendor); | ||
3415 | + g_signal_connect(G_OBJECT(model), "row-changed", | ||
3416 | + G_CALLBACK(status_update), data); | ||
3417 | |||
3418 | return data; | ||
3419 | } | ||
3420 | @@ -230,112 +252,108 @@ static void select_callback(GtkTreeSelection *selection, gpointer user_data) | ||
3421 | return; | ||
3422 | } | ||
3423 | |||
3424 | - if (data == NULL) { | ||
3425 | - data = create_config(model, &iter, user_data); | ||
3426 | - if (data == NULL) | ||
3427 | - return; | ||
3428 | + if (current_data) { | ||
3429 | + g_signal_handlers_disconnect_by_func(G_OBJECT(model), | ||
3430 | + G_CALLBACK(status_update), current_data); | ||
3431 | + g_free(current_data); | ||
3432 | + } | ||
3433 | + data = create_config(model, &iter, user_data); | ||
3434 | + if (data == NULL) | ||
3435 | + return; | ||
3436 | |||
3437 | - page = gtk_notebook_append_page(GTK_NOTEBOOK(notebook), | ||
3438 | - data->widget, NULL); | ||
3439 | - } else { | ||
3440 | - update_config(data); | ||
3441 | + current_data = data; | ||
3442 | |||
3443 | - page = gtk_notebook_page_num(GTK_NOTEBOOK(notebook), | ||
3444 | - data->widget); | ||
3445 | - } | ||
3446 | + page = gtk_notebook_append_page(GTK_NOTEBOOK(notebook), | ||
3447 | + data->widget, NULL); | ||
3448 | |||
3449 | gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), page); | ||
3450 | - | ||
3451 | gtk_widget_show(notebook); | ||
3452 | } | ||
3453 | |||
3454 | -static void row_changed(GtkTreeModel *model, GtkTreePath *path, | ||
3455 | - GtkTreeIter *iter, gpointer user_data) | ||
3456 | +static void device_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell, | ||
3457 | + GtkTreeModel *model, GtkTreeIter *iter, gpointer data) | ||
3458 | { | ||
3459 | guint type; | ||
3460 | - gboolean powered, inrange; | ||
3461 | + char *markup, *name, *state; | ||
3462 | + const char *title; | ||
3463 | |||
3464 | gtk_tree_model_get(model, iter, CONNMAN_COLUMN_TYPE, &type, | ||
3465 | - CONNMAN_COLUMN_ENABLED, &powered, | ||
3466 | - CONNMAN_COLUMN_INRANGE, &inrange, -1); | ||
3467 | -} | ||
3468 | - | ||
3469 | -static void state_to_icon(GtkTreeViewColumn *column, GtkCellRenderer *cell, | ||
3470 | - GtkTreeModel *model, GtkTreeIter *iter, gpointer data) | ||
3471 | -{ | ||
3472 | - gboolean inrange; | ||
3473 | - | ||
3474 | - gtk_tree_model_get(model, iter, CONNMAN_COLUMN_INRANGE, &inrange, -1); | ||
3475 | - | ||
3476 | - if (inrange == TRUE) | ||
3477 | - g_object_set(cell, "icon-name", GTK_STOCK_YES, NULL); | ||
3478 | - else | ||
3479 | - g_object_set(cell, "icon-name", NULL, NULL); | ||
3480 | -} | ||
3481 | - | ||
3482 | -static void type_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell, | ||
3483 | - GtkTreeModel *model, GtkTreeIter *iter, gpointer data) | ||
3484 | -{ | ||
3485 | - guint type; | ||
3486 | - gboolean powered, inrange; | ||
3487 | - gchar *markup; | ||
3488 | - const char *title, *info; | ||
3489 | - | ||
3490 | - gtk_tree_model_get(model, iter, CONNMAN_COLUMN_TYPE, &type, | ||
3491 | - CONNMAN_COLUMN_ENABLED, &powered, | ||
3492 | - CONNMAN_COLUMN_INRANGE, &inrange, -1); | ||
3493 | + CONNMAN_COLUMN_NAME, &name, | ||
3494 | + CONNMAN_COLUMN_STATE, &state, | ||
3495 | + -1); | ||
3496 | |||
3497 | switch (type) { | ||
3498 | case CONNMAN_TYPE_ETHERNET: | ||
3499 | title = N_("Ethernet"); | ||
3500 | + markup = g_strdup_printf(" %s\n", title); | ||
3501 | break; | ||
3502 | case CONNMAN_TYPE_WIFI: | ||
3503 | - title = N_("Wireless"); | ||
3504 | + /* Show the AP name */ | ||
3505 | + title = N_(name); | ||
3506 | + if (g_str_equal(state, "association") == TRUE) | ||
3507 | + state = "associating..."; | ||
3508 | + else if (g_str_equal(state, "configuration") == TRUE) | ||
3509 | + state = "configurating..."; | ||
3510 | + else if (g_str_equal(state, "ready") == TRUE || | ||
3511 | + g_str_equal(state, "online") == TRUE) | ||
3512 | + state = "connnected"; | ||
3513 | + else | ||
3514 | + state = ""; | ||
3515 | + markup = g_strdup_printf(" %s\n %s", title, state); | ||
3516 | + | ||
3517 | break; | ||
3518 | case CONNMAN_TYPE_WIMAX: | ||
3519 | title = N_("WiMAX"); | ||
3520 | + markup = g_strdup_printf(" %s\n", title); | ||
3521 | break; | ||
3522 | case CONNMAN_TYPE_BLUETOOTH: | ||
3523 | title = N_("Bluetooth"); | ||
3524 | + markup = g_strdup_printf(" %s\n", title); | ||
3525 | + break; | ||
3526 | + case CONNMAN_TYPE_LABEL_ETHERNET: | ||
3527 | + title = N_("Wired Networks"); | ||
3528 | + markup = g_strdup_printf("<b>\n%s\n</b>", title); | ||
3529 | + break; | ||
3530 | + case CONNMAN_TYPE_LABEL_WIFI: | ||
3531 | + title = N_("Wireless Networks"); | ||
3532 | + markup = g_strdup_printf("<b>\n%s\n</b>", title); | ||
3533 | + break; | ||
3534 | + case CONNMAN_TYPE_SYSCONFIG: | ||
3535 | + title = N_("System Configuration"); | ||
3536 | + markup = g_strdup_printf("<b>\n%s\n</b>", title); | ||
3537 | break; | ||
3538 | default: | ||
3539 | title = N_("Unknown"); | ||
3540 | + markup = g_strdup_printf(" %s\n", title); | ||
3541 | break; | ||
3542 | } | ||
3543 | |||
3544 | - if (powered == TRUE) { | ||
3545 | - if (inrange == TRUE) | ||
3546 | - info = N_("Connected"); | ||
3547 | - else | ||
3548 | - info = N_("Not Connected"); | ||
3549 | - } else | ||
3550 | - info = N_("Disabled"); | ||
3551 | - | ||
3552 | - markup = g_strdup_printf("<b>%s</b>\n<small>%s</small>", title, info); | ||
3553 | g_object_set(cell, "markup", markup, NULL); | ||
3554 | - g_free(markup); | ||
3555 | } | ||
3556 | |||
3557 | static void type_to_icon(GtkTreeViewColumn *column, GtkCellRenderer *cell, | ||
3558 | - GtkTreeModel *model, GtkTreeIter *iter, gpointer data) | ||
3559 | + GtkTreeModel *model, GtkTreeIter *iter, gpointer data) | ||
3560 | { | ||
3561 | - guint type; | ||
3562 | + guint type, strength; | ||
3563 | + char *name; | ||
3564 | |||
3565 | - gtk_tree_model_get(model, iter, CONNMAN_COLUMN_TYPE, &type, -1); | ||
3566 | + gtk_tree_model_get(model, iter, CONNMAN_COLUMN_TYPE, &type, | ||
3567 | + CONNMAN_COLUMN_STRENGTH, &strength, | ||
3568 | + -1); | ||
3569 | |||
3570 | switch (type) { | ||
3571 | - case CONNMAN_TYPE_ETHERNET: | ||
3572 | + case CONNMAN_TYPE_WIFI: | ||
3573 | + name = g_strdup_printf("connman-signal-0%d", (strength-1)/20+1); | ||
3574 | + g_object_set(cell, "icon-name", name, | ||
3575 | + "stock-size", 4, NULL); | ||
3576 | + break; | ||
3577 | + case CONNMAN_TYPE_LABEL_ETHERNET: | ||
3578 | g_object_set(cell, "icon-name", "network-wired", | ||
3579 | - "stock-size", 5, NULL); | ||
3580 | + "stock-size", 4, NULL); | ||
3581 | break; | ||
3582 | - case CONNMAN_TYPE_WIFI: | ||
3583 | - case CONNMAN_TYPE_WIMAX: | ||
3584 | + case CONNMAN_TYPE_LABEL_WIFI: | ||
3585 | g_object_set(cell, "icon-name", "network-wireless", | ||
3586 | - "stock-size", 5, NULL); | ||
3587 | - break; | ||
3588 | - case CONNMAN_TYPE_BLUETOOTH: | ||
3589 | - g_object_set(cell, "icon-name", "bluetooth", | ||
3590 | - "stock-size", 5, NULL); | ||
3591 | + "stock-size", 4, NULL); | ||
3592 | break; | ||
3593 | default: | ||
3594 | g_object_set(cell, "icon-name", NULL, NULL); | ||
3595 | @@ -362,40 +380,34 @@ static GtkWidget *create_interfaces(GtkWidget *window) | ||
3596 | |||
3597 | scrolled = gtk_scrolled_window_new(NULL, NULL); | ||
3598 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), | ||
3599 | - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | ||
3600 | + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | ||
3601 | gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), | ||
3602 | - GTK_SHADOW_OUT); | ||
3603 | + GTK_SHADOW_OUT); | ||
3604 | gtk_box_pack_start(GTK_BOX(hbox), scrolled, FALSE, TRUE, 0); | ||
3605 | |||
3606 | tree = gtk_tree_view_new(); | ||
3607 | gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE); | ||
3608 | gtk_tree_view_set_show_expanders(GTK_TREE_VIEW(tree), FALSE); | ||
3609 | gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree), TRUE); | ||
3610 | - gtk_widget_set_size_request(tree, 180, -1); | ||
3611 | + gtk_widget_set_size_request(tree, 220, -1); | ||
3612 | gtk_container_add(GTK_CONTAINER(scrolled), tree); | ||
3613 | |||
3614 | |||
3615 | column = gtk_tree_view_column_new(); | ||
3616 | gtk_tree_view_column_set_expand(column, TRUE); | ||
3617 | gtk_tree_view_column_set_spacing(column, 4); | ||
3618 | + gtk_tree_view_column_set_alignment(column, 0); | ||
3619 | gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); | ||
3620 | |||
3621 | renderer = gtk_cell_renderer_pixbuf_new(); | ||
3622 | - gtk_cell_renderer_set_fixed_size(renderer, 20, 45); | ||
3623 | gtk_tree_view_column_pack_start(column, renderer, FALSE); | ||
3624 | gtk_tree_view_column_set_cell_data_func(column, renderer, | ||
3625 | - state_to_icon, NULL, NULL); | ||
3626 | + type_to_icon, NULL, NULL); | ||
3627 | |||
3628 | renderer = gtk_cell_renderer_text_new(); | ||
3629 | - gtk_tree_view_column_pack_start(column, renderer, TRUE); | ||
3630 | - gtk_tree_view_column_set_cell_data_func(column, renderer, | ||
3631 | - type_to_text, NULL, NULL); | ||
3632 | - | ||
3633 | - renderer = gtk_cell_renderer_pixbuf_new(); | ||
3634 | - gtk_tree_view_column_pack_end(column, renderer, FALSE); | ||
3635 | + gtk_tree_view_column_pack_start(column, renderer, FALSE); | ||
3636 | gtk_tree_view_column_set_cell_data_func(column, renderer, | ||
3637 | - type_to_icon, NULL, NULL); | ||
3638 | - | ||
3639 | + device_to_text, NULL, NULL); | ||
3640 | |||
3641 | interface_notebook = gtk_notebook_new(); | ||
3642 | gtk_notebook_set_show_tabs(GTK_NOTEBOOK(interface_notebook), FALSE); | ||
3643 | @@ -405,21 +417,19 @@ static GtkWidget *create_interfaces(GtkWidget *window) | ||
3644 | |||
3645 | model = connman_client_get_device_model(client); | ||
3646 | gtk_tree_view_set_model(GTK_TREE_VIEW(tree), model); | ||
3647 | + | ||
3648 | g_object_unref(model); | ||
3649 | |||
3650 | selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); | ||
3651 | gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); | ||
3652 | g_signal_connect(G_OBJECT(selection), "changed", | ||
3653 | - G_CALLBACK(select_callback), window); | ||
3654 | - | ||
3655 | - g_signal_connect(G_OBJECT(model), "row-changed", | ||
3656 | - G_CALLBACK(row_changed), selection); | ||
3657 | + G_CALLBACK(select_callback), window); | ||
3658 | |||
3659 | return mainbox; | ||
3660 | } | ||
3661 | |||
3662 | static gboolean delete_callback(GtkWidget *window, GdkEvent *event, | ||
3663 | - gpointer user_data) | ||
3664 | + gpointer user_data) | ||
3665 | { | ||
3666 | gtk_widget_destroy(window); | ||
3667 | |||
3668 | @@ -451,7 +461,7 @@ static GtkWidget *create_window(void) | ||
3669 | gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); | ||
3670 | gtk_window_set_default_size(GTK_WINDOW(window), 580, 380); | ||
3671 | g_signal_connect(G_OBJECT(window), "delete-event", | ||
3672 | - G_CALLBACK(delete_callback), NULL); | ||
3673 | + G_CALLBACK(delete_callback), NULL); | ||
3674 | |||
3675 | vbox = gtk_vbox_new(FALSE, 12); | ||
3676 | gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); | ||
3677 | @@ -467,12 +477,12 @@ static GtkWidget *create_window(void) | ||
3678 | button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | ||
3679 | gtk_container_add(GTK_CONTAINER(buttonbox), button); | ||
3680 | g_signal_connect(G_OBJECT(button), "clicked", | ||
3681 | - G_CALLBACK(close_callback), window); | ||
3682 | + G_CALLBACK(close_callback), window); | ||
3683 | |||
3684 | widget = create_interfaces(window); | ||
3685 | gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook), widget, NULL); | ||
3686 | gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(notebook), | ||
3687 | - widget, _("Devices")); | ||
3688 | + widget, _("Services")); | ||
3689 | |||
3690 | gtk_widget_show_all(window); | ||
3691 | |||
3692 | @@ -487,6 +497,8 @@ int main(int argc, char *argv[]) | ||
3693 | bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); | ||
3694 | textdomain(GETTEXT_PACKAGE); | ||
3695 | |||
3696 | + current_data = NULL; | ||
3697 | + | ||
3698 | gtk_init(&argc, &argv); | ||
3699 | |||
3700 | gtk_window_set_default_icon_name("network-wireless"); | ||
3701 | diff --git a/properties/wifi.c b/properties/wifi.c | ||
3702 | index 320dce4..42fe7d2 100644 | ||
3703 | --- a/properties/wifi.c | ||
3704 | +++ b/properties/wifi.c | ||
3705 | @@ -23,6 +23,7 @@ | ||
3706 | #include <config.h> | ||
3707 | #endif | ||
3708 | |||
3709 | +#include <dbus/dbus-glib.h> | ||
3710 | #include <glib/gi18n.h> | ||
3711 | #include <gtk/gtk.h> | ||
3712 | |||
3713 | @@ -30,6 +31,24 @@ | ||
3714 | |||
3715 | #include "advanced.h" | ||
3716 | |||
3717 | +static void update_wifi_ipv4(struct config_data *data, guint policy); | ||
3718 | + | ||
3719 | +static gboolean separator_function(GtkTreeModel *model, | ||
3720 | + GtkTreeIter *iter, gpointer user_data) | ||
3721 | +{ | ||
3722 | + gchar *text; | ||
3723 | + gboolean result = FALSE; | ||
3724 | + | ||
3725 | + gtk_tree_model_get(model, iter, 0, &text, -1); | ||
3726 | + | ||
3727 | + if (text && *text == '\0') | ||
3728 | + result = TRUE; | ||
3729 | + | ||
3730 | + g_free(text); | ||
3731 | + | ||
3732 | + return result; | ||
3733 | +} | ||
3734 | + | ||
3735 | static void changed_callback(GtkWidget *editable, gpointer user_data) | ||
3736 | { | ||
3737 | struct config_data *data = user_data; | ||
3738 | @@ -37,98 +56,357 @@ static void changed_callback(GtkWidget *editable, gpointer user_data) | ||
3739 | |||
3740 | active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->policy.config)); | ||
3741 | |||
3742 | - switch (active) { | ||
3743 | - case 0: | ||
3744 | - connman_client_set_policy(data->client, data->device, "auto"); | ||
3745 | - update_wifi_policy(data, CONNMAN_POLICY_AUTO); | ||
3746 | - break; | ||
3747 | - case 1: | ||
3748 | - connman_client_set_policy(data->client, data->device, "manual"); | ||
3749 | - update_wifi_policy(data, CONNMAN_POLICY_MANUAL); | ||
3750 | - break; | ||
3751 | - case 3: | ||
3752 | - connman_client_set_policy(data->client, data->device, "off"); | ||
3753 | - update_wifi_policy(data, CONNMAN_POLICY_OFF); | ||
3754 | - break; | ||
3755 | + update_wifi_ipv4(data, active); | ||
3756 | +} | ||
3757 | + | ||
3758 | +static void connect_reply_cb(DBusGProxy *proxy, GError *error, | ||
3759 | + gpointer user_data) | ||
3760 | +{ | ||
3761 | + if (error) | ||
3762 | + g_error_free(error); | ||
3763 | +} | ||
3764 | + | ||
3765 | +static void connect_callback(GtkWidget *editable, gpointer user_data) | ||
3766 | +{ | ||
3767 | + struct config_data *data = user_data; | ||
3768 | + | ||
3769 | + gboolean ret; | ||
3770 | + gint active; | ||
3771 | + | ||
3772 | + if (data->wifi.passphrase) { | ||
3773 | + char *passphrase; | ||
3774 | + passphrase = (gchar *)gtk_entry_get_text(GTK_ENTRY(data->wifi.passphrase)); | ||
3775 | + ret = connman_client_set_passphrase(data->client, data->device, | ||
3776 | + passphrase); | ||
3777 | + | ||
3778 | + if (ret == FALSE) { | ||
3779 | + return; | ||
3780 | + } | ||
3781 | } | ||
3782 | + | ||
3783 | + active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->policy.config)); | ||
3784 | + data->ipv4_config.method = active ? "manual" : "dhcp"; | ||
3785 | + data->ipv4_config.address = active ? gtk_entry_get_text(GTK_ENTRY(data->ipv4.entry[0])) : NULL; | ||
3786 | + data->ipv4_config.netmask = active ? gtk_entry_get_text(GTK_ENTRY(data->ipv4.entry[1])) : NULL; | ||
3787 | + data->ipv4_config.gateway = active ? gtk_entry_get_text(GTK_ENTRY(data->ipv4.entry[2])) : NULL; | ||
3788 | + ret = connman_client_set_ipv4(data->client, data->device, &data->ipv4_config); | ||
3789 | + if (ret == FALSE) { | ||
3790 | + return; | ||
3791 | + } | ||
3792 | + | ||
3793 | + connman_client_connect_async(data->client, data->device, connect_reply_cb, data); | ||
3794 | } | ||
3795 | |||
3796 | -void add_wifi_policy(GtkWidget *mainbox, struct config_data *data) | ||
3797 | +static void disconnect_callback(GtkWidget *editable, gpointer user_data) | ||
3798 | +{ | ||
3799 | + struct config_data *data = user_data; | ||
3800 | + | ||
3801 | + connman_client_disconnect(data->client, data->device); | ||
3802 | +} | ||
3803 | + | ||
3804 | +static void switch_callback(GtkWidget *editable, gpointer user_data) | ||
3805 | +{ | ||
3806 | + struct config_data *data = user_data; | ||
3807 | + const gchar *label = gtk_button_get_label(GTK_BUTTON(data->wifi_button)); | ||
3808 | + | ||
3809 | + if (g_str_equal(label, "Disable")) | ||
3810 | + connman_client_disable_technology(data->client, data->device, "wifi"); | ||
3811 | + else | ||
3812 | + connman_client_enable_technology(data->client, data->device, "wifi"); | ||
3813 | +} | ||
3814 | + | ||
3815 | +static void scan_reply_cb(DBusGProxy *proxy, GError *error, | ||
3816 | + gpointer user_data) | ||
3817 | +{ | ||
3818 | + GtkWidget *button = user_data; | ||
3819 | + gtk_widget_set_sensitive(button, 1); | ||
3820 | + | ||
3821 | + if (error) | ||
3822 | + g_error_free(error); | ||
3823 | +} | ||
3824 | + | ||
3825 | +static void scan_callback(GtkWidget *button, gpointer user_data) | ||
3826 | +{ | ||
3827 | + struct config_data *data = user_data; | ||
3828 | + gtk_widget_set_sensitive(button, 0); | ||
3829 | + connman_client_request_scan(data->client, "", scan_reply_cb, button); | ||
3830 | +} | ||
3831 | + | ||
3832 | +void add_wifi_switch_button(GtkWidget *mainbox, GtkTreeIter *iter, | ||
3833 | + struct config_data *data) | ||
3834 | { | ||
3835 | GtkWidget *vbox; | ||
3836 | GtkWidget *table; | ||
3837 | GtkWidget *label; | ||
3838 | - GtkWidget *combo; | ||
3839 | + GtkWidget *buttonbox; | ||
3840 | + GtkWidget *button; | ||
3841 | + gboolean wifi_enabled; | ||
3842 | |||
3843 | - vbox = gtk_vbox_new(FALSE, 0); | ||
3844 | + gtk_tree_model_get(data->model, iter, | ||
3845 | + CONNMAN_COLUMN_WIFI_ENABLED, &wifi_enabled, | ||
3846 | + -1); | ||
3847 | + | ||
3848 | + vbox = gtk_vbox_new(TRUE, 0); | ||
3849 | gtk_container_set_border_width(GTK_CONTAINER(vbox), 24); | ||
3850 | gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0); | ||
3851 | |||
3852 | - table = gtk_table_new(2, 4, FALSE); | ||
3853 | - gtk_table_set_row_spacings(GTK_TABLE(table), 8); | ||
3854 | - gtk_table_set_col_spacings(GTK_TABLE(table), 8); | ||
3855 | + table = gtk_table_new(1, 1, TRUE); | ||
3856 | + gtk_table_set_row_spacings(GTK_TABLE(table), 10); | ||
3857 | + gtk_table_set_col_spacings(GTK_TABLE(table), 10); | ||
3858 | gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | ||
3859 | |||
3860 | -#if 0 | ||
3861 | - label = gtk_label_new(_("Network Name:")); | ||
3862 | - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); | ||
3863 | - gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); | ||
3864 | + label = gtk_label_new(_("Configure Wifi Networks.")); | ||
3865 | gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | ||
3866 | |||
3867 | - combo = gtk_combo_box_new_text(); | ||
3868 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Guest"); | ||
3869 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), ""); | ||
3870 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Off"); | ||
3871 | - gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(combo), | ||
3872 | - separator_function, NULL, NULL); | ||
3873 | - gtk_table_attach_defaults(GTK_TABLE(table), combo, 1, 4, 0, 1); | ||
3874 | - data->policy.config = combo; | ||
3875 | -#endif | ||
3876 | + buttonbox = gtk_hbutton_box_new(); | ||
3877 | + gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonbox), GTK_BUTTONBOX_CENTER); | ||
3878 | + gtk_box_pack_start(GTK_BOX(mainbox), buttonbox, FALSE, FALSE, 0); | ||
3879 | + | ||
3880 | + button = gtk_button_new(); | ||
3881 | + data->wifi_button = button; | ||
3882 | + | ||
3883 | + if (wifi_enabled) | ||
3884 | + gtk_button_set_label(GTK_BUTTON(button), _("Disable")); | ||
3885 | + else | ||
3886 | + gtk_button_set_label(GTK_BUTTON(button), _("Enable")); | ||
3887 | + | ||
3888 | + gtk_container_add(GTK_CONTAINER(buttonbox), button); | ||
3889 | + g_signal_connect(G_OBJECT(button), "clicked", | ||
3890 | + G_CALLBACK(switch_callback), data); | ||
3891 | + | ||
3892 | + button = gtk_button_new_with_label(_("Scan")); | ||
3893 | + data->scan_button = button; | ||
3894 | + | ||
3895 | + if (!wifi_enabled) | ||
3896 | + gtk_widget_set_sensitive(button, 0); | ||
3897 | + | ||
3898 | + gtk_container_add(GTK_CONTAINER(buttonbox), button); | ||
3899 | + g_signal_connect(G_OBJECT(button), "clicked", | ||
3900 | + G_CALLBACK(scan_callback), data); | ||
3901 | +} | ||
3902 | + | ||
3903 | + | ||
3904 | +static void wifi_ipconfig(GtkWidget *table, struct config_data *data, GtkTreeIter *iter) | ||
3905 | +{ | ||
3906 | + GtkWidget *entry; | ||
3907 | + GtkWidget *label; | ||
3908 | + GtkWidget *combo; | ||
3909 | + DBusGProxy *proxy; | ||
3910 | + | ||
3911 | + struct ipv4_config ipv4_config = { | ||
3912 | + .method = NULL, | ||
3913 | + .address = NULL, | ||
3914 | + .netmask = NULL, | ||
3915 | + .gateway = NULL, | ||
3916 | + }; | ||
3917 | + | ||
3918 | + gtk_tree_model_get(data->model, iter, | ||
3919 | + CONNMAN_COLUMN_PROXY, &proxy, | ||
3920 | + CONNMAN_COLUMN_METHOD, &ipv4_config.method, | ||
3921 | + CONNMAN_COLUMN_ADDRESS, &ipv4_config.address, | ||
3922 | + CONNMAN_COLUMN_NETMASK, &ipv4_config.netmask, | ||
3923 | + CONNMAN_COLUMN_GATEWAY, &ipv4_config.gateway, | ||
3924 | + -1); | ||
3925 | |||
3926 | label = gtk_label_new(_("Configuration:")); | ||
3927 | - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); | ||
3928 | - gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); | ||
3929 | - gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | ||
3930 | + gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 3, 4); | ||
3931 | + data->ipv4.label[0] = label; | ||
3932 | |||
3933 | combo = gtk_combo_box_new_text(); | ||
3934 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Automatically"); | ||
3935 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Manually"); | ||
3936 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), ""); | ||
3937 | - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Off"); | ||
3938 | + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "DHCP"); | ||
3939 | + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Manual"); | ||
3940 | gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(combo), | ||
3941 | - separator_function, NULL, NULL); | ||
3942 | - gtk_table_attach_defaults(GTK_TABLE(table), combo, 1, 4, 0, 1); | ||
3943 | + separator_function, NULL, NULL); | ||
3944 | + | ||
3945 | + gtk_table_attach_defaults(GTK_TABLE(table), combo, 2, 4, 3, 4); | ||
3946 | data->policy.config = combo; | ||
3947 | |||
3948 | - label = gtk_label_new(NULL); | ||
3949 | - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | ||
3950 | + label = gtk_label_new(_("IP address:")); | ||
3951 | + gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 4, 5); | ||
3952 | + data->ipv4.label[0] = label; | ||
3953 | + | ||
3954 | + entry = gtk_entry_new(); | ||
3955 | + gtk_entry_set_max_length (GTK_ENTRY (entry), 15); | ||
3956 | + if (ipv4_config.address) | ||
3957 | + gtk_entry_set_text(GTK_ENTRY(entry), ipv4_config.address); | ||
3958 | + gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 4, 4, 5); | ||
3959 | + data->ipv4.entry[0] = entry; | ||
3960 | + | ||
3961 | + label = gtk_label_new(_("Netmask:")); | ||
3962 | + gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 5, 6); | ||
3963 | + data->ipv4.label[1] = label; | ||
3964 | + | ||
3965 | + entry = gtk_entry_new(); | ||
3966 | + gtk_entry_set_max_length (GTK_ENTRY (entry), 15); | ||
3967 | + if (ipv4_config.netmask) | ||
3968 | + gtk_entry_set_text(GTK_ENTRY(entry), ipv4_config.netmask); | ||
3969 | + gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 4, 5, 6); | ||
3970 | + data->ipv4.entry[1] = entry; | ||
3971 | + | ||
3972 | + label = gtk_label_new(_("Gateway:")); | ||
3973 | + gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 6, 7); | ||
3974 | + data->ipv4.label[2] = label; | ||
3975 | + | ||
3976 | + entry = gtk_entry_new(); | ||
3977 | + gtk_entry_set_max_length (GTK_ENTRY (entry), 15); | ||
3978 | + if (ipv4_config.gateway) | ||
3979 | + gtk_entry_set_text(GTK_ENTRY(entry), ipv4_config.gateway); | ||
3980 | + gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 4, 6, 7); | ||
3981 | + data->ipv4.entry[2] = entry; | ||
3982 | + | ||
3983 | + data->ipv4_config = ipv4_config; | ||
3984 | + | ||
3985 | + if (g_str_equal(ipv4_config.method, "dhcp") == TRUE) | ||
3986 | + update_wifi_ipv4(data, CONNMAN_POLICY_DHCP); | ||
3987 | + else | ||
3988 | + update_wifi_ipv4(data, CONNMAN_POLICY_MANUAL); | ||
3989 | + | ||
3990 | + g_signal_connect(G_OBJECT(combo), "changed", | ||
3991 | + G_CALLBACK(changed_callback), data); | ||
3992 | +} | ||
3993 | + | ||
3994 | +static void toggled_callback(GtkWidget *button, gpointer user_data) | ||
3995 | +{ | ||
3996 | + GtkWidget *entry = user_data; | ||
3997 | + gboolean mode; | ||
3998 | + | ||
3999 | + mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); | ||
4000 | + | ||
4001 | + gtk_entry_set_visibility(GTK_ENTRY(entry), mode); | ||
4002 | +} | ||
4003 | + | ||
4004 | +void add_wifi_policy(GtkWidget *mainbox, GtkTreeIter *iter, struct config_data *data) | ||
4005 | +{ | ||
4006 | + GtkWidget *vbox; | ||
4007 | + GtkWidget *table; | ||
4008 | + GtkWidget *label; | ||
4009 | + GtkWidget *entry; | ||
4010 | + GtkWidget *button; | ||
4011 | + | ||
4012 | + const char *name, *security, *icon, *state; | ||
4013 | + guint strength; | ||
4014 | + | ||
4015 | + gtk_tree_model_get(data->model, iter, | ||
4016 | + CONNMAN_COLUMN_NAME, &name, | ||
4017 | + CONNMAN_COLUMN_SECURITY, &security, | ||
4018 | + CONNMAN_COLUMN_ICON, &icon, | ||
4019 | + CONNMAN_COLUMN_STATE, &state, | ||
4020 | + CONNMAN_COLUMN_STRENGTH, &strength, | ||
4021 | + -1); | ||
4022 | + | ||
4023 | + if (g_str_equal(state, "failure") == TRUE) | ||
4024 | + connman_client_remove(data->client, data->device); | ||
4025 | + | ||
4026 | + vbox = gtk_vbox_new(TRUE, 0); | ||
4027 | + gtk_container_set_border_width(GTK_CONTAINER(vbox), 24); | ||
4028 | + gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0); | ||
4029 | + | ||
4030 | + table = gtk_table_new(10, 5, TRUE); | ||
4031 | + gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | ||
4032 | + data->table = table; | ||
4033 | + | ||
4034 | + label = gtk_label_new(_("Access Point:")); | ||
4035 | + gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1); | ||
4036 | + | ||
4037 | + label = gtk_label_new(_(name)); | ||
4038 | + gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 4, 0, 1); | ||
4039 | gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | ||
4040 | + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | ||
4041 | + data->wifi.name = label; | ||
4042 | + | ||
4043 | + label = gtk_label_new(_("Security:")); | ||
4044 | + gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); | ||
4045 | + | ||
4046 | + label = gtk_label_new(_(security)); | ||
4047 | + gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 4, 1, 2); | ||
4048 | + gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | ||
4049 | + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | ||
4050 | + data->wifi.security = label; | ||
4051 | + | ||
4052 | + label = gtk_label_new(_("Passphrase:")); | ||
4053 | + gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3); | ||
4054 | + | ||
4055 | + if (g_str_equal(security, "none") != TRUE && | ||
4056 | + g_str_equal(security, "unknown") != TRUE) { | ||
4057 | + entry = gtk_entry_new(); | ||
4058 | + gtk_entry_set_max_length (GTK_ENTRY (entry), 64); | ||
4059 | + gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 4, 2, 3); | ||
4060 | + gtk_entry_set_visibility(GTK_ENTRY(entry), 0); | ||
4061 | + data->wifi.passphrase = entry; | ||
4062 | + | ||
4063 | + button = gtk_check_button_new_with_label(_("Show input")); | ||
4064 | + gtk_table_attach_defaults(GTK_TABLE(table), button, 4, 5, 2, 3); | ||
4065 | + | ||
4066 | + g_signal_connect(G_OBJECT(button), "toggled", | ||
4067 | + G_CALLBACK(toggled_callback), entry); | ||
4068 | + | ||
4069 | + | ||
4070 | + } else { | ||
4071 | + label = gtk_label_new(_("none")); | ||
4072 | + gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 4, 2, 3); | ||
4073 | + gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | ||
4074 | + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | ||
4075 | + data->wifi.passphrase = NULL; | ||
4076 | + } | ||
4077 | + | ||
4078 | + label = gtk_label_new(_("")); | ||
4079 | + gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 3, 8, 9); | ||
4080 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); | ||
4081 | - gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 4, 1, 2); | ||
4082 | - gtk_widget_set_size_request(label, 180, -1); | ||
4083 | - data->policy.label = label; | ||
4084 | + gtk_widget_hide(label); | ||
4085 | + data->wifi.connect_info = label; | ||
4086 | |||
4087 | - g_signal_connect(G_OBJECT(combo), "changed", | ||
4088 | - G_CALLBACK(changed_callback), data); | ||
4089 | + button = gtk_button_new_with_label(_("Connect")); | ||
4090 | + gtk_table_attach_defaults(GTK_TABLE(table), button, 3, 4, 8, 9); | ||
4091 | + g_signal_connect(G_OBJECT(button), "clicked", | ||
4092 | + G_CALLBACK(connect_callback), data); | ||
4093 | + gtk_widget_set_no_show_all(button, TRUE); | ||
4094 | + data->wifi.connect = button; | ||
4095 | + | ||
4096 | + button = gtk_button_new_with_label(_("Disconnect")); | ||
4097 | + gtk_table_attach_defaults(GTK_TABLE(table), button, 3, 4, 8, 9); | ||
4098 | + g_signal_connect(G_OBJECT(button), "clicked", | ||
4099 | + G_CALLBACK(disconnect_callback), data); | ||
4100 | + data->wifi.disconnect = button; | ||
4101 | + gtk_widget_set_no_show_all(button, TRUE); | ||
4102 | + | ||
4103 | + if (g_str_equal(state, "failure") == TRUE | ||
4104 | + || g_str_equal(state, "idle") == TRUE) { | ||
4105 | + gtk_widget_show(data->wifi.connect); | ||
4106 | + gtk_widget_hide(data->wifi.disconnect); | ||
4107 | + } else { | ||
4108 | + gtk_widget_hide(data->wifi.connect); | ||
4109 | + gtk_widget_show(data->wifi.disconnect); | ||
4110 | + } | ||
4111 | + | ||
4112 | + wifi_ipconfig(table, data, iter); | ||
4113 | } | ||
4114 | |||
4115 | -void update_wifi_policy(struct config_data *data, guint policy) | ||
4116 | +void update_wifi_ipv4(struct config_data *data, guint policy) | ||
4117 | { | ||
4118 | GtkWidget *combo = data->policy.config; | ||
4119 | - gchar *info = NULL; | ||
4120 | + GtkWidget *entry[3]; | ||
4121 | + int i; | ||
4122 | + | ||
4123 | + for (i = 0; i < 3; i++) | ||
4124 | + entry[i] = data->ipv4.entry[i]; | ||
4125 | |||
4126 | g_signal_handlers_block_by_func(G_OBJECT(combo), | ||
4127 | - G_CALLBACK(changed_callback), data); | ||
4128 | + G_CALLBACK(changed_callback), data); | ||
4129 | |||
4130 | switch (policy) { | ||
4131 | - case CONNMAN_POLICY_OFF: | ||
4132 | - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 3); | ||
4133 | + case CONNMAN_POLICY_DHCP: | ||
4134 | + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); | ||
4135 | + for (i = 0; i < 3; i++) { | ||
4136 | + gtk_entry_set_editable(GTK_ENTRY(entry[i]), 0); | ||
4137 | + gtk_widget_set_sensitive(entry[i], 0); | ||
4138 | + } | ||
4139 | break; | ||
4140 | case CONNMAN_POLICY_MANUAL: | ||
4141 | gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 1); | ||
4142 | - break; | ||
4143 | - case CONNMAN_POLICY_AUTO: | ||
4144 | - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); | ||
4145 | + for (i = 0; i < 3; i++) { | ||
4146 | + gtk_entry_set_editable(GTK_ENTRY(entry[i]), 1); | ||
4147 | + gtk_widget_set_sensitive(entry[i], 1); | ||
4148 | + } | ||
4149 | break; | ||
4150 | default: | ||
4151 | gtk_combo_box_set_active(GTK_COMBO_BOX(combo), -1); | ||
4152 | @@ -136,9 +414,5 @@ void update_wifi_policy(struct config_data *data, guint policy) | ||
4153 | } | ||
4154 | |||
4155 | g_signal_handlers_unblock_by_func(G_OBJECT(combo), | ||
4156 | - G_CALLBACK(changed_callback), data); | ||
4157 | - | ||
4158 | - gtk_label_set_markup(GTK_LABEL(data->policy.label), info); | ||
4159 | - | ||
4160 | - g_free(info); | ||
4161 | + G_CALLBACK(changed_callback), data); | ||
4162 | } | ||
diff --git a/meta/recipes-connectivity/connman/connman-gnome/remove-connman-property-desktop-file.patch b/meta/recipes-connectivity/connman/connman-gnome/remove-connman-property-desktop-file.patch deleted file mode 100644 index 2a8cff3593..0000000000 --- a/meta/recipes-connectivity/connman/connman-gnome/remove-connman-property-desktop-file.patch +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | diff -ruN connman-gnome-0.5-orig/po/POTFILES.in connman-gnome-0.5/po/POTFILES.in | ||
2 | --- connman-gnome-0.5-orig/po/POTFILES.in 2010-12-16 16:03:29.000000000 +0800 | ||
3 | +++ connman-gnome-0.5/po/POTFILES.in 2010-12-17 10:27:17.000000000 +0800 | ||
4 | @@ -4,4 +4,3 @@ | ||
5 | properties/advanced.c | ||
6 | properties/ethernet.c | ||
7 | properties/wifi.c | ||
8 | -properties/connman-properties.desktop.in | ||
9 | diff -ruN connman-gnome-0.5-orig/properties/Makefile.am connman-gnome-0.5/properties/Makefile.am | ||
10 | --- connman-gnome-0.5-orig/properties/Makefile.am 2010-12-16 16:03:29.000000000 +0800 | ||
11 | +++ connman-gnome-0.5/properties/Makefile.am 2010-12-17 10:27:09.000000000 +0800 | ||
12 | @@ -17,16 +17,6 @@ | ||
13 | |||
14 | INCLUDES = -I$(top_srcdir)/common | ||
15 | |||
16 | -desktopdir = $(datadir)/applications | ||
17 | - | ||
18 | -desktop_in_files = connman-properties.desktop.in | ||
19 | - | ||
20 | -desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) | ||
21 | - | ||
22 | @INTLTOOL_DESKTOP_RULE@ | ||
23 | |||
24 | -CLEANFILES = $(desktop_DATA) | ||
25 | - | ||
26 | -EXTRA_DIST = $(desktop_in_files) | ||
27 | - | ||
28 | MAINTAINERCLEANFILES = Makefile.in | ||
29 | diff -ruN connman-gnome-0.5-orig/properties/connman-properties.desktop.in connman-gnome-0.5/properties/connman-properties.desktop.in | ||
30 | --- connman-gnome-0.5-orig/properties/connman-properties.desktop.in 2010-12-16 16:03:29.000000000 +0800 | ||
31 | +++ connman-gnome-0.5/properties/connman-properties.desktop.in 1970-01-01 08:00:00.000000000 +0800 | ||
32 | @@ -1,10 +0,0 @@ | ||
33 | -[Desktop Entry] | ||
34 | -Encoding=UTF-8 | ||
35 | -_Name=Connection Management | ||
36 | -_Comment=Configure connection management | ||
37 | -Icon=stock_internet | ||
38 | -Exec=connman-properties | ||
39 | -Terminal=false | ||
40 | -Type=Application | ||
41 | -Categories=Settings; | ||
42 | -OnlyShowIn=GNOME; | ||
diff --git a/meta/recipes-connectivity/connman/connman-gnome/service_name_update.patch b/meta/recipes-connectivity/connman/connman-gnome/service_name_update.patch deleted file mode 100644 index 942cfc883c..0000000000 --- a/meta/recipes-connectivity/connman/connman-gnome/service_name_update.patch +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | diff -ruN connman-gnome-0.5-orig/common/connman-dbus.h connman-gnome-0.5/common/connman-dbus.h | ||
2 | --- connman-gnome-0.5-orig/common/connman-dbus.h 2010-12-30 09:45:03.312043457 +0800 | ||
3 | +++ connman-gnome-0.5/common/connman-dbus.h 2010-12-30 09:45:33.978499439 +0800 | ||
4 | @@ -22,7 +22,7 @@ | ||
5 | #include <dbus/dbus-glib.h> | ||
6 | #include <gtk/gtk.h> | ||
7 | |||
8 | -#define CONNMAN_SERVICE "org.moblin.connman" | ||
9 | +#define CONNMAN_SERVICE "net.connman" | ||
10 | |||
11 | #define CONNMAN_ERROR_INTERFACE CONNMAN_SERVICE ".Error" | ||
12 | #define CONNMAN_AGENT_INTERFACE CONNMAN_SERVICE ".Agent" | ||
13 | diff -ruN connman-gnome-0.5-orig/common/instance.c connman-gnome-0.5/common/instance.c | ||
14 | --- connman-gnome-0.5-orig/common/instance.c 2010-12-30 09:45:03.316085542 +0800 | ||
15 | +++ connman-gnome-0.5/common/instance.c 2010-12-30 09:46:01.654479049 +0800 | ||
16 | @@ -29,7 +29,7 @@ | ||
17 | |||
18 | #include "instance.h" | ||
19 | |||
20 | -#define CONNMAN_SERVICE "org.moblin.connman" | ||
21 | +#define CONNMAN_SERVICE "net.connman" | ||
22 | #define CONNMAN_INSTANCE CONNMAN_SERVICE ".Instance" | ||
23 | |||
24 | static DBusGConnection *connection; | ||
25 | diff -ruN connman-gnome-0.5-orig/common/instance.xml connman-gnome-0.5/common/instance.xml | ||
26 | --- connman-gnome-0.5-orig/common/instance.xml 2010-12-30 09:45:03.312043457 +0800 | ||
27 | +++ connman-gnome-0.5/common/instance.xml 2010-12-30 09:45:49.868372780 +0800 | ||
28 | @@ -1,7 +1,7 @@ | ||
29 | <?xml version="1.0" encoding="UTF-8" ?> | ||
30 | |||
31 | <node name="/"> | ||
32 | - <interface name="org.moblin.connman.Instance"> | ||
33 | + <interface name="net.connman.Instance"> | ||
34 | <method name="Present"> | ||
35 | </method> | ||
36 | </interface> | ||
diff --git a/meta/recipes-connectivity/connman/connman-gnome_0.5.bb b/meta/recipes-connectivity/connman/connman-gnome_0.5.bb index 4fcdfaf25b..69b2d5bc18 100644 --- a/meta/recipes-connectivity/connman/connman-gnome_0.5.bb +++ b/meta/recipes-connectivity/connman/connman-gnome_0.5.bb | |||
@@ -6,17 +6,12 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=eb723b61539feef013de476e68b5c50a \ | |||
6 | file://properties/main.c;beginline=1;endline=20;md5=50c77c81871308b033ab7a1504626afb \ | 6 | file://properties/main.c;beginline=1;endline=20;md5=50c77c81871308b033ab7a1504626afb \ |
7 | file://common/connman-dbus.c;beginline=1;endline=20;md5=de6b485c0e717a0236402d220187717a" | 7 | file://common/connman-dbus.c;beginline=1;endline=20;md5=de6b485c0e717a0236402d220187717a" |
8 | DEPENDS = "gtk+ dbus" | 8 | DEPENDS = "gtk+ dbus" |
9 | PR = "r4" | 9 | PR = "r5" |
10 | 10 | ||
11 | RRECOMMENDS_${PN} = "python python-dbus connman connman-plugin-ethernet connman-plugin-loopback connman-plugin-udhcp connman-plugin-wifi connman-plugin-fake connman-plugin-bluetooth connman-plugin-dnsproxy" | 11 | RRECOMMENDS_${PN} = "python python-dbus connman connman-plugin-ethernet connman-plugin-loopback connman-plugin-udhcp connman-plugin-wifi connman-plugin-fake connman-plugin-bluetooth connman-plugin-dnsproxy" |
12 | 12 | ||
13 | SRC_URI = "${KERNELORG_MIRROR}/linux/network/connman/connman-gnome-${PV}.tar.gz \ | 13 | SRCREV = "78d3c39db6f3f7977b466305110faa8ca5f74ec8" |
14 | file://connman-gnome.patch \ | 14 | SRC_URI = "git://git.kernel.org/pub/scm/network/connman/connman-gnome.git;protocol=git" |
15 | file://remove-connman-property-desktop-file.patch \ | 15 | S = "${WORKDIR}/git" |
16 | file://service_name_update.patch \ | ||
17 | file://applet_menu_popup_fix.patch" | ||
18 | |||
19 | SRC_URI[md5sum] = "0e1c4c25d19cad9b08a216848a320716" | ||
20 | SRC_URI[sha256sum] = "4d5fe481b444fc3e64fd9caa149dbcd76de166a25733f18fd93da01d2abf5d1c" | ||
21 | 16 | ||
22 | inherit autotools gtk-icon-cache | 17 | inherit autotools gtk-icon-cache |