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