diff options
author | Dongxiao Xu <dongxiao.xu@intel.com> | 2010-08-26 13:37:52 +0800 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-08-27 15:46:55 +0100 |
commit | ca4a58a4eb66e6e08f358de7f8869a35389ee605 (patch) | |
tree | 915bdde88c353517b1763907ca41c02745635bc2 | |
parent | f6917ad47b0425f9ccb3965aa9220ed3ba0e49ec (diff) | |
download | openembedded-core-ca4a58a4eb66e6e08f358de7f8869a35389ee605.tar.gz openembedded-core-ca4a58a4eb66e6e08f358de7f8869a35389ee605.tar.bz2 openembedded-core-ca4a58a4eb66e6e08f358de7f8869a35389ee605.tar.xz openembedded-core-ca4a58a4eb66e6e08f358de7f8869a35389ee605.zip |
connman: Use connman as default network management tool
Upgrade connman to version 0.56
Modify connman-gnome to match the recent version of connman
Deprecate networkmanager
Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
15 files changed, 3684 insertions, 74 deletions
diff --git a/meta-extras/packages/tasks/task-poky-x11-netbook.bb b/meta-extras/packages/tasks/task-poky-x11-netbook.bb index a5ebb5407..9c5d9ce30 100644 --- a/meta-extras/packages/tasks/task-poky-x11-netbook.bb +++ b/meta-extras/packages/tasks/task-poky-x11-netbook.bb @@ -15,7 +15,7 @@ PACKAGE_ARCH = "${MACHINE_ARCH}" ALLOW_EMPTY = "1" -NETWORK_MANAGER ?= "networkmanager-applet" +NETWORK_MANAGER ?= "connman-gnome" RDEPENDS_task-poky-x11-netbook = "\ mutter \ matchbox-desktop \ diff --git a/meta/packages/resolvconf/resolvconf_1.43.bb b/meta/packages/resolvconf/resolvconf_1.43.bb index 2c210ef1e..f751f17e0 100644 --- a/meta/packages/resolvconf/resolvconf_1.43.bb +++ b/meta/packages/resolvconf/resolvconf_1.43.bb @@ -9,6 +9,7 @@ AUTHOR = "Thomas Hood" HOMEPAGE = "http://packages.debian.org/resolvconf" DEPENDS = "bash" RDEPENDS = "bash" +PR = "r1" SRC_URI = "${DEBIAN_MIRROR}/main/r/resolvconf/resolvconf_${PV}.tar.gz" @@ -17,7 +18,7 @@ do_compile () { } do_install () { - install -d ${D}${sysconfdir} ${D}${sbindir} ${D}${base_sbindir} ${D}${localstatedir}/run/resolvconf/interface + install -d ${D}${sysconfdir} ${D}${sbindir} ${D}${base_sbindir} ${D}${localstatedir}/volatile/run/resolvconf/interface install -d ${D}${mandir}/man8 ${D}${docdir}/${P} cp -pPR etc/* ${D}${sysconfdir}/ install -m 0755 bin/resolvconf ${D}${base_sbindir}/ diff --git a/meta/recipes-connectivity/connman/files/connman b/meta/recipes-connectivity/connman/connman-0.56/connman index f8154f68f..f8154f68f 100755 --- a/meta/recipes-connectivity/connman/files/connman +++ b/meta/recipes-connectivity/connman/connman-0.56/connman diff --git a/meta/recipes-connectivity/connman/files/dbusperms.patch b/meta/recipes-connectivity/connman/connman-0.56/dbusperms.patch index 100af0367..100af0367 100644 --- a/meta/recipes-connectivity/connman/files/dbusperms.patch +++ b/meta/recipes-connectivity/connman/connman-0.56/dbusperms.patch 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 000000000..83d96ee67 --- /dev/null +++ b/meta/recipes-connectivity/connman/connman-gnome/connman-applet.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=Connection Manager +Comment=Connection Manager applet +Icon=stock_internet +Exec=connman-applet +Terminal=false +Type=Application +Categories=Network;GTK; + 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 000000000..52b105e47 --- /dev/null +++ b/meta/recipes-connectivity/connman/connman-gnome/connman-gnome.patch @@ -0,0 +1,3612 @@ +connman-gnome: Change the code to fit recent connman + +The recent connman changes from "device" based to "service" based. +Therefore most of the interaction protocol between connman and +connman-gnome has changed. This commit uses the new dbus interface +to interact with connman. With this change, connman-gnome could +do wired and wireless interface configurations with latest connman. + +Besides, some UI is re-designed to be more neat and friendly to +end user. + +Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com> + +diff --git a/applet/main.c b/applet/main.c +index 2a9b36e..1243a41 100644 +--- a/applet/main.c ++++ b/applet/main.c +@@ -108,138 +108,8 @@ static void toggled_callback(GtkWidget *button, gpointer user_data) + gtk_entry_set_visibility(GTK_ENTRY(entry), mode); + } + +-static void passphrase_dialog(const char *path, const char *name) +-{ +- GtkWidget *dialog; +- GtkWidget *button; +- GtkWidget *image; +- GtkWidget *label; +- GtkWidget *entry; +- GtkWidget *table; +- GtkWidget *vbox; +- +- dialog = gtk_dialog_new(); +- gtk_window_set_title(GTK_WINDOW(dialog), _("Enter passphrase")); +- gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); +- gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); +- gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE); +- gtk_window_set_urgency_hint(GTK_WINDOW(dialog), TRUE); +- gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); +- +- button = gtk_dialog_add_button(GTK_DIALOG(dialog), +- GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT); +- button = gtk_dialog_add_button(GTK_DIALOG(dialog), +- GTK_STOCK_OK, GTK_RESPONSE_ACCEPT); +- gtk_widget_grab_default(button); +- +- table = gtk_table_new(5, 2, FALSE); +- gtk_table_set_row_spacings(GTK_TABLE(table), 4); +- gtk_table_set_col_spacings(GTK_TABLE(table), 20); +- gtk_container_set_border_width(GTK_CONTAINER(table), 12); +- gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table); +- image = gtk_image_new_from_icon_name(GTK_STOCK_DIALOG_AUTHENTICATION, +- GTK_ICON_SIZE_DIALOG); +- gtk_misc_set_alignment(GTK_MISC(image), 0.0, 0.0); +- gtk_table_attach(GTK_TABLE(table), image, 0, 1, 0, 5, +- GTK_SHRINK, GTK_FILL, 0, 0); +- vbox = gtk_vbox_new(FALSE, 6); +- +- label = gtk_label_new(_("Network requires input of a passphrase:")); +- gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); +- gtk_container_add(GTK_CONTAINER(vbox), label); +- gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 0, 1, +- GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0); +- +- entry = gtk_entry_new(); +- gtk_entry_set_max_length(GTK_ENTRY(entry), 120); +- gtk_entry_set_width_chars(GTK_ENTRY(entry), 20); +- gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); +- gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); +- gtk_container_add(GTK_CONTAINER(vbox), entry); +- +- button = gtk_check_button_new_with_label(_("Show input")); +- gtk_container_add(GTK_CONTAINER(vbox), button); +- +- g_signal_connect(G_OBJECT(button), "toggled", +- G_CALLBACK(toggled_callback), entry); +- +- button = gtk_check_button_new_with_label(_("Remember network")); +- gtk_container_add(GTK_CONTAINER(vbox), button); +- +- gtk_widget_show_all(dialog); +- +- if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { +- const gchar *passphrase; +- gboolean remember; +- +- passphrase = gtk_entry_get_text(GTK_ENTRY(entry)); +- remember = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); +- +- connman_client_set_passphrase(client, path, passphrase); +- connman_client_set_remember(client, path, remember); +- +- status_prepare(); +- connman_client_connect(client, path); +- } +- +- gtk_widget_destroy(dialog); +-} +- +-static void activate_callback(GtkWidget *item, gpointer user_data) +-{ +- const gchar *path = user_data; +- guint security; +- gchar *passphrase; +- +- security = connman_client_get_security(client, path); +- if (security == CONNMAN_SECURITY_UNKNOWN) +- return; +- +- if (security == CONNMAN_SECURITY_NONE) { +- status_prepare(); +- connman_client_connect(client, path); +- return; +- } +- +- passphrase = connman_client_get_passphrase(client, path); +- if (passphrase != NULL) { +- g_free(passphrase); +- +- status_prepare(); +- connman_client_connect(client, path); +- return; +- } +- +- passphrase_dialog(path, NULL); +-} +- +-static void disconnect_callback(GtkWidget *item, gpointer user_data) +-{ +- connman_client_disconnect(client, NULL); +-} +- +-static GtkWidget *create_popupmenu(void) +-{ +- GtkWidget *menu; +- GtkWidget *item; +- +- menu = gtk_menu_new(); +- +- item = gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES, NULL); +- g_signal_connect(item, "activate", G_CALLBACK(settings_callback), NULL); +- gtk_widget_show(item); +- gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); +- +- item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, NULL); +- g_signal_connect(item, "activate", G_CALLBACK(about_callback), NULL); +- gtk_widget_show(item); +- gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); +- +- return menu; +-} +- + static GtkWidget *append_menuitem(GtkMenu *menu, const char *ssid, +- guint security, guint strength) ++ gchar *security, guint strength) + { + GtkWidget *item; + GtkWidget *hbox; +@@ -263,7 +133,7 @@ static GtkWidget *append_menuitem(GtkMenu *menu, const char *ssid, + image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION, + GTK_ICON_SIZE_MENU); + gtk_misc_set_alignment(GTK_MISC(image), 1.0, 0.5); +- if (security != CONNMAN_SECURITY_NONE) { ++ if (security && g_str_equal(security, "none") != TRUE) { + gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); + gtk_widget_show(image); + } +@@ -281,96 +151,21 @@ static GtkWidget *append_menuitem(GtkMenu *menu, const char *ssid, + return item; + } + +-static void enumerate_networks(GtkMenu *menu, +- GtkTreeModel *model, GtkTreeIter *parent) +-{ +- GtkTreeIter iter; +- gboolean cont; +- +- cont = gtk_tree_model_iter_children(model, &iter, parent); +- +- while (cont == TRUE) { +- GtkWidget *item; +- DBusGProxy *proxy; +- guint strength, security; +- gchar *name, *path; +- gboolean inrange, connected; +- +- gtk_tree_model_get(model, &iter, +- CONNMAN_COLUMN_PROXY, &proxy, +- CONNMAN_COLUMN_NAME, &name, +- CONNMAN_COLUMN_INRANGE, &inrange, +- CONNMAN_COLUMN_ENABLED, &connected, +- CONNMAN_COLUMN_STRENGTH, &strength, +- CONNMAN_COLUMN_SECURITY, &security, -1); +- +- if (connected == TRUE || inrange == TRUE) { +- item = append_menuitem(menu, name, security, strength); +- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), +- connected); +- +- path = g_strdup(dbus_g_proxy_get_path(proxy)); +- g_signal_connect(item, "activate", +- G_CALLBACK(activate_callback), path); +- } +- +- g_free(name); +- +- cont = gtk_tree_model_iter_next(model, &iter); +- } +-} +- + static gboolean menu_callback(GtkMenu *menu) + { +- GtkTreeModel *model; +- GtkTreeIter parent; + GtkWidget *item; +- gboolean cont; +- +- connman_client_propose_scan(client, NULL); +- +- model = connman_client_get_device_network_model(client); +- +- cont = gtk_tree_model_get_iter_first(model, &parent); +- +- while (cont == TRUE) { +- guint type; +- gchar *name; +- +- gtk_tree_model_get(model, &parent, +- CONNMAN_COLUMN_TYPE, &type, +- CONNMAN_COLUMN_NAME, &name, -1); +- +- switch (type) { +- case CONNMAN_TYPE_WIFI: +- case CONNMAN_TYPE_WIMAX: +- enumerate_networks(menu, model, &parent); +- break; +- default: +- break; +- } +- +- g_free(name); +- +- cont = gtk_tree_model_iter_next(model, &parent); +- } +- +- g_object_unref(model); + + item = gtk_separator_menu_item_new(); + gtk_widget_show(item); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + +- item = gtk_menu_item_new_with_label(_("Disconnect Network")); +- g_signal_connect(item, "activate", +- G_CALLBACK(disconnect_callback), NULL); ++ item = gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES, NULL); ++ g_signal_connect(item, "activate", G_CALLBACK(settings_callback), NULL); + gtk_widget_show(item); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + +- item = gtk_menu_item_new_with_label(_("Join Other Network...")); +- gtk_widget_set_sensitive(item, FALSE); +- //g_signal_connect(item, "activate", +- // G_CALLBACK(join_callback), NULL); ++ item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, NULL); ++ g_signal_connect(item, "activate", G_CALLBACK(about_callback), NULL); + gtk_widget_show(item); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + +@@ -387,16 +182,17 @@ static void update_status(GtkTreeModel *model) + cont = gtk_tree_model_get_iter_first(model, &iter); + + while (cont == TRUE) { +- gboolean enabled; ++ gchar *state; + + gtk_tree_model_get(model, &iter, + CONNMAN_COLUMN_TYPE, &type, + CONNMAN_COLUMN_STRENGTH, &strength, +- CONNMAN_COLUMN_ENABLED, &enabled, -1); ++ CONNMAN_COLUMN_STATE, &state, -1); + + online = TRUE; + +- if (enabled == TRUE) ++ if ((type == CONNMAN_TYPE_ETHERNET && (g_str_equal(state, "idle") || g_str_equal(state, "online"))) || ++ (type == CONNMAN_TYPE_WIFI && (g_str_equal(state, "ready") || g_str_equal(state, "online")))) + break; + + cont = gtk_tree_model_iter_next(model, &iter); +@@ -453,7 +249,7 @@ int main(int argc, char *argv[]) + + g_set_application_name(_("Connection Manager")); + +- status_init(menu_callback, create_popupmenu()); ++ status_init(menu_callback); + + client = connman_client_new(); + model = connman_client_get_connection_model(client); +diff --git a/applet/status.c b/applet/status.c +index ef11bcc..13ec752 100644 +--- a/applet/status.c ++++ b/applet/status.c +@@ -170,19 +170,6 @@ static void activate_callback(GObject *object, gpointer user_data) + GTK_STATUS_ICON(object), 1, activate_time); + } + +-static void popup_callback(GObject *object, guint button, +- guint activate_time, gpointer user_data) +-{ +- GtkMenu *menu = user_data; +- +- if (menu == NULL) +- return; +- +- gtk_menu_popup(menu, NULL, NULL, +- gtk_status_icon_position_menu, +- GTK_STATUS_ICON(object), button, activate_time); +-} +- + static GtkIconTheme *icontheme; + static IconAnimation *animation; + static GdkPixbuf *pixbuf_notifier; +@@ -190,7 +177,7 @@ static GdkPixbuf *pixbuf_none; + static GdkPixbuf *pixbuf_wired; + static GdkPixbuf *pixbuf_signal[5]; + +-int status_init(StatusCallback activate, GtkWidget *popup) ++int status_init(StatusCallback activate) + { + GdkScreen *screen; + +@@ -219,9 +206,6 @@ int status_init(StatusCallback activate, GtkWidget *popup) + g_signal_connect(statusicon, "activate", + G_CALLBACK(activate_callback), activate); + +- g_signal_connect(statusicon, "popup-menu", +- G_CALLBACK(popup_callback), popup); +- + return 0; + } + +@@ -292,8 +276,6 @@ void status_config(void) + + static void set_ready(gint signal) + { +- int index; +- + available = TRUE; + + if (signal < 0) { +@@ -302,12 +284,7 @@ static void set_ready(gint signal) + return; + } + +- if (signal == 0) +- index = 0; +- else +- index = 3; +- +- gtk_status_icon_set_from_pixbuf(statusicon, pixbuf_signal[index]); ++ gtk_status_icon_set_from_pixbuf(statusicon, pixbuf_signal[4]); + gtk_status_icon_set_tooltip(statusicon, NULL); + } + +diff --git a/applet/status.h b/applet/status.h +index 772a7b2..8a3c83c 100644 +--- a/applet/status.h ++++ b/applet/status.h +@@ -21,7 +21,7 @@ + + typedef gboolean (* StatusCallback) (GtkMenu *menu); + +-int status_init(StatusCallback activate, GtkWidget *popup); ++int status_init(StatusCallback activate); + void status_cleanup(void); + + void status_unavailable(void); +diff --git a/common/Makefile.am b/common/Makefile.am +index ff3a996..8d74a46 100644 +--- a/common/Makefile.am ++++ b/common/Makefile.am +@@ -5,13 +5,6 @@ libcommon_a_SOURCES = connman-dbus.c connman-dbus.h \ + connman-client.h connman-client.c \ + instance.h instance.c + +-noinst_PROGRAMS = connman-demo test-client +- +-connman_demo_SOURCES = demo.c +-connman_demo_LDADD = libcommon.a @GTK_LIBS@ @DBUS_LIBS@ +- +-test_client_LDADD = libcommon.a @GTK_LIBS@ @DBUS_LIBS@ +- + BUILT_SOURCES = marshal.h marshal.c \ + connman-dbus-glue.h \ + instance-glue.h +diff --git a/common/connman-client.c b/common/connman-client.c +index aad0a22..96f9388 100644 +--- a/common/connman-client.c ++++ b/common/connman-client.c +@@ -98,10 +98,9 @@ static void connman_client_init(ConnmanClient *client) + + priv->store = gtk_tree_store_new(_CONNMAN_NUM_COLUMNS, G_TYPE_OBJECT, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, +- G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, +- G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING, +- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, +- G_TYPE_STRING); ++ G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, ++ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, ++ G_TYPE_STRING, G_TYPE_STRING); + + g_object_set_data(G_OBJECT(priv->store), + "State", g_strdup("unavailable")); +@@ -197,7 +196,7 @@ static gboolean device_filter(GtkTreeModel *model, + if (proxy == NULL) + return FALSE; + +- active = g_str_equal(CONNMAN_DEVICE_INTERFACE, ++ active = g_str_equal(CONNMAN_SERVICE_INTERFACE, + dbus_g_proxy_get_interface(proxy)); + + g_object_unref(proxy); +@@ -231,10 +230,10 @@ static gboolean device_network_filter(GtkTreeModel *model, + if (proxy == NULL) + return FALSE; + +- active = g_str_equal(CONNMAN_DEVICE_INTERFACE, ++ active = g_str_equal(CONNMAN_SERVICE_INTERFACE, + dbus_g_proxy_get_interface(proxy)); + if (active == FALSE) +- active = g_str_equal(CONNMAN_NETWORK_INTERFACE, ++ active = g_str_equal(CONNMAN_SERVICE_INTERFACE, + dbus_g_proxy_get_interface(proxy)); + + g_object_unref(proxy); +@@ -277,7 +276,7 @@ GtkTreeModel *connman_client_get_network_model(ConnmanClient *client, + gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter, + CONNMAN_COLUMN_PROXY, &proxy, -1); + +- if (g_str_equal(CONNMAN_DEVICE_INTERFACE, ++ if (g_str_equal(CONNMAN_SERVICE_INTERFACE, + dbus_g_proxy_get_interface(proxy)) == TRUE) + found = g_str_has_prefix(dbus_g_proxy_get_path(proxy), + device); +@@ -314,7 +313,7 @@ static gboolean connection_filter(GtkTreeModel *model, + if (proxy == NULL) + return FALSE; + +- active = g_str_equal(CONNMAN_CONNECTION_INTERFACE, ++ active = g_str_equal(CONNMAN_SERVICE_INTERFACE, + dbus_g_proxy_get_interface(proxy)); + + g_object_unref(proxy); +@@ -337,12 +336,19 @@ GtkTreeModel *connman_client_get_connection_model(ConnmanClient *client) + return model; + } + +-void connman_client_set_policy(ConnmanClient *client, const gchar *device, +- const gchar *policy) ++void connman_client_set_ipv4(ConnmanClient *client, const gchar *device, ++ struct ipv4_config *ipv4_config) + { + ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); + DBusGProxy *proxy; + GValue value = { 0 }; ++ gboolean ret; ++ GHashTable *ipv4 = g_hash_table_new(g_str_hash, g_str_equal); ++ ++ g_hash_table_insert(ipv4, "Method", (gpointer)ipv4_config->method); ++ g_hash_table_insert(ipv4, "Address", (gpointer)ipv4_config->address); ++ g_hash_table_insert(ipv4, "Netmask", (gpointer)ipv4_config->netmask); ++ g_hash_table_insert(ipv4, "Gateway", (gpointer)ipv4_config->gateway); + + DBG("client %p", client); + +@@ -353,10 +359,10 @@ void connman_client_set_policy(ConnmanClient *client, const gchar *device, + if (proxy == NULL) + return; + +- g_value_init(&value, G_TYPE_STRING); +- g_value_set_string(&value, policy); ++ g_value_init(&value, DBUS_TYPE_G_STRING_STRING_HASHTABLE); ++ g_value_set_boxed(&value, ipv4); + +- connman_set_property(proxy, "Policy", &value, NULL); ++ ret = connman_set_property(proxy, "IPv4.Configuration", &value, NULL); + + g_object_unref(proxy); + } +@@ -389,26 +395,22 @@ static gboolean device_scan(GtkTreeModel *model, GtkTreePath *path, + GtkTreeIter *iter, gpointer user_data) + { + DBusGProxy *proxy; +- gboolean enabled; + + gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy, +- CONNMAN_COLUMN_ENABLED, &enabled, -1); ++ -1); + + if (proxy == NULL) + return FALSE; + + if (g_str_equal(dbus_g_proxy_get_interface(proxy), +- CONNMAN_DEVICE_INTERFACE) == FALSE) +- return FALSE; +- +- if (enabled == FALSE) ++ CONNMAN_SERVICE_INTERFACE) == FALSE) + return FALSE; + + connman_propose_scan(proxy, NULL); + + g_object_unref(proxy); + +- return FALSE; ++ return TRUE; + } + + void connman_client_propose_scan(ConnmanClient *client, const gchar *device) +@@ -437,46 +439,85 @@ static gboolean network_disconnect(GtkTreeModel *model, GtkTreePath *path, + GtkTreeIter *iter, gpointer user_data) + { + DBusGProxy *proxy; +- gboolean enabled; ++ gchar *name; ++ guint type; + + gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy, +- CONNMAN_COLUMN_ENABLED, &enabled, -1); ++ CONNMAN_COLUMN_NAME, &name, ++ CONNMAN_COLUMN_TYPE, &type, ++ -1); + + if (proxy == NULL) +- return FALSE; ++ return TRUE; + + if (g_str_equal(dbus_g_proxy_get_interface(proxy), +- CONNMAN_NETWORK_INTERFACE) == FALSE) +- return FALSE; ++ CONNMAN_SERVICE_INTERFACE) == FALSE) ++ return TRUE; + +- if (enabled == TRUE) ++ if (type == CONNMAN_TYPE_WIFI) + connman_disconnect(proxy, NULL); + + g_object_unref(proxy); + +- return enabled; ++ return FALSE; + } + +-void connman_client_connect(ConnmanClient *client, const gchar *network) ++gboolean connman_client_connect(ConnmanClient *client, const gchar *network) + { + ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); + DBusGProxy *proxy; ++ gboolean ret = FALSE; + + DBG("client %p", client); ++ DBG("network %s", network); + + if (network == NULL) +- return; ++ goto done; + + gtk_tree_model_foreach(GTK_TREE_MODEL(priv->store), + network_disconnect, NULL); + + proxy = connman_dbus_get_proxy(priv->store, network); + if (proxy == NULL) +- return; ++ goto done; + +- connman_connect(proxy, NULL); ++ ret = connman_connect(proxy, NULL); + + g_object_unref(proxy); ++ ++done: ++ return ret; ++} ++ ++void connman_client_connect_async(ConnmanClient *client, const gchar *network, ++ connman_connect_reply callback, gpointer userdata) ++{ ++ ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); ++ DBusGProxy *proxy; ++ ++ DBG("client %p", client); ++ DBG("network %s", network); ++ ++ if (network == NULL) ++ goto done; ++ ++ gtk_tree_model_foreach(GTK_TREE_MODEL(priv->store), ++ network_disconnect, NULL); ++ ++ proxy = connman_dbus_get_proxy(priv->store, network); ++ if (proxy == NULL) ++ goto done; ++ ++ /* Set an unusually long timeout because the Connect ++ * method doesn't return until there has been either ++ * success or an error. ++ */ ++ dbus_g_proxy_set_default_timeout(proxy, 120000); ++ connman_connect_async(proxy, callback, userdata); ++ dbus_g_proxy_set_default_timeout(proxy, -1); ++ ++done: ++ return; + } + + static void connman_client_disconnect_all(ConnmanClient *client) +@@ -487,32 +528,37 @@ static void connman_client_disconnect_all(ConnmanClient *client) + network_disconnect, NULL); + } + +-void connman_client_disconnect(ConnmanClient *client, const gchar *network) ++gboolean connman_client_disconnect(ConnmanClient *client, const gchar *network) + { + ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); + DBusGProxy *proxy; ++ gboolean ret = FALSE; + + DBG("client %p", client); + + if (network == NULL) { ++ ret = TRUE; + connman_client_disconnect_all(client); +- return; ++ goto done; + } + + proxy = connman_dbus_get_proxy(priv->store, network); + if (proxy == NULL) +- return; ++ goto done; + +- connman_disconnect(proxy, NULL); ++ ret = connman_disconnect(proxy, NULL); + + g_object_unref(proxy); ++ ++done: ++ return ret; + } + +-guint connman_client_get_security(ConnmanClient *client, const gchar *network) ++gchar *connman_client_get_security(ConnmanClient *client, const gchar *network) + { + ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); + GtkTreeIter iter; +- guint security; ++ gchar *security; + + DBG("client %p", client); + +@@ -548,56 +594,37 @@ gchar *connman_client_get_passphrase(ConnmanClient *client, const gchar *network + return passphrase; + } + +-void connman_client_set_passphrase(ConnmanClient *client, const gchar *network, ++gboolean connman_client_set_passphrase(ConnmanClient *client, const gchar *network, + const gchar *passphrase) + { + ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); + DBusGProxy *proxy; + GValue value = { 0 }; ++ gboolean ret = FALSE; + + DBG("client %p", client); ++ DBG("network %p", network); + + if (network == NULL) +- return; ++ goto done; + + proxy = connman_dbus_get_proxy(priv->store, network); + if (proxy == NULL) +- return; ++ goto done; + ++ DBG("passphrase %s", passphrase); + g_value_init(&value, G_TYPE_STRING); + g_value_set_string(&value, passphrase); + +- connman_set_property(proxy, "WiFi.Passphrase", &value, NULL); +- +- g_value_unset(&value); +- +- g_object_unref(proxy); +-} +- +-void connman_client_set_remember(ConnmanClient *client, const gchar *network, +- gboolean remember) +-{ +- ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); +- DBusGProxy *proxy; +- GValue value = { 0 }; +- +- DBG("client %p", client); +- +- if (network == NULL) +- return; +- +- proxy = connman_dbus_get_proxy(priv->store, network); +- if (proxy == NULL) +- return; +- +- g_value_init(&value, G_TYPE_BOOLEAN); +- g_value_set_boolean(&value, remember); +- +- connman_set_property(proxy, "Remember", &value, NULL); ++ ret = connman_set_property(proxy, "Passphrase", &value, NULL); ++ DBG("passphrase setting succeeded? %d", ret); ++ DBG("false is ? %d", FALSE); + + g_value_unset(&value); + + g_object_unref(proxy); ++done: ++ return ret; + } + + void connman_client_set_callback(ConnmanClient *client, +diff --git a/common/connman-client.h b/common/connman-client.h +index f30dae4..f3ac1d3 100644 +--- a/common/connman-client.h ++++ b/common/connman-client.h +@@ -23,6 +23,7 @@ + #define __CONNMAN_CLIENT_H + + #include <gtk/gtk.h> ++#include "connman-dbus-glue.h" + + G_BEGIN_DECLS + +@@ -49,6 +50,13 @@ struct _ConnmanClientClass { + GObjectClass parent_class; + }; + ++struct ipv4_config { ++ const gchar *method; ++ const gchar *address; ++ const gchar *netmask; ++ const gchar *gateway; ++}; ++ + GType connman_client_get_type(void); + + ConnmanClient *connman_client_new(void); +@@ -60,18 +68,20 @@ GtkTreeModel *connman_client_get_network_model(ConnmanClient *client, + const gchar *device); + GtkTreeModel *connman_client_get_connection_model(ConnmanClient *client); + +-void connman_client_set_policy(ConnmanClient *client, const gchar *device, +- const gchar *policy); + void connman_client_set_powered(ConnmanClient *client, const gchar *device, + gboolean powered); + void connman_client_propose_scan(ConnmanClient *client, const gchar *device); + +-void connman_client_connect(ConnmanClient *client, const gchar *network); +-void connman_client_disconnect(ConnmanClient *client, const gchar *network); ++gboolean connman_client_connect(ConnmanClient *client, const gchar *network); ++ ++void connman_client_connect_async(ConnmanClient *client, const gchar *network, ++ connman_connect_reply callback, gpointer userdata); + +-guint connman_client_get_security(ConnmanClient *client, const gchar *network); ++gboolean connman_client_disconnect(ConnmanClient *client, const gchar *network); ++ ++gchar *connman_client_get_security(ConnmanClient *client, const gchar *network); + gchar *connman_client_get_passphrase(ConnmanClient *client, const gchar *network); +-void connman_client_set_passphrase(ConnmanClient *client, const gchar *network, ++gboolean connman_client_set_passphrase(ConnmanClient *client, const gchar *network, + const gchar *passphrase); + void connman_client_set_remember(ConnmanClient *client, const gchar *network, + gboolean remember); +@@ -81,22 +91,27 @@ typedef void (* ConnmanClientCallback) (const char *status, void *user_data); + void connman_client_set_callback(ConnmanClient *client, + ConnmanClientCallback callback, gpointer user_data); + ++void connman_client_set_ipv4(ConnmanClient *client, const gchar *device, ++ struct ipv4_config *ipv4_config); ++ ++gboolean connman_dbus_get_iter(GtkTreeStore *store, const gchar *path, ++ GtkTreeIter *iter); + enum { + CONNMAN_COLUMN_PROXY, /* G_TYPE_OBJECT */ ++ CONNMAN_COLUMN_STATE, /* G_TYPE_STRING */ + CONNMAN_COLUMN_NAME, /* G_TYPE_STRING */ +- CONNMAN_COLUMN_ICON, /* G_TYPE_STRING */ + CONNMAN_COLUMN_TYPE, /* G_TYPE_UINT */ +- CONNMAN_COLUMN_ENABLED, /* G_TYPE_BOOLEAN */ +- CONNMAN_COLUMN_INRANGE, /* G_TYPE_BOOLEAN */ +- CONNMAN_COLUMN_REMEMBER, /* G_TYPE_BOOLEAN */ ++ CONNMAN_COLUMN_ICON, /* G_TYPE_STRING */ + CONNMAN_COLUMN_STRENGTH, /* G_TYPE_UINT */ +- CONNMAN_COLUMN_SECURITY, /* G_TYPE_UINT */ ++ CONNMAN_COLUMN_SECURITY, /* G_TYPE_STRING */ + CONNMAN_COLUMN_PASSPHRASE, /* G_TYPE_STRING */ +- CONNMAN_COLUMN_NETWORK, +- CONNMAN_COLUMN_ADDRESS, +- CONNMAN_COLUMN_POLICY, +- CONNMAN_COLUMN_DEVICE, +- _CONNMAN_NUM_COLUMNS ++ ++ CONNMAN_COLUMN_METHOD, /* G_TYPE_STRING */ ++ CONNMAN_COLUMN_ADDRESS, /* G_TYPE_STRING */ ++ CONNMAN_COLUMN_NETMASK, /* G_TYPE_STRING */ ++ CONNMAN_COLUMN_GATEWAY, /* G_TYPE_STRING */ ++ _CONNMAN_NUM_COLUMNS, ++ + }; + + enum { +@@ -108,10 +123,7 @@ enum { + }; + + enum { +- CONNMAN_POLICY_UNKNOWN, +- CONNMAN_POLICY_IGNORE, +- CONNMAN_POLICY_OFF, +- CONNMAN_POLICY_AUTO, ++ CONNMAN_POLICY_DHCP, + CONNMAN_POLICY_MANUAL, + }; + +diff --git a/common/connman-dbus.c b/common/connman-dbus.c +index 9eba7ae..83f4e57 100644 +--- a/common/connman-dbus.c ++++ b/common/connman-dbus.c +@@ -159,20 +159,22 @@ static gint compare_path(gconstpointer a, gconstpointer b) + return g_strcmp0(a, b); + } + ++static gint compare_list(gchar *path_a, gchar *path_b, gpointer user_data) ++{ ++ return g_strcmp0(path_a, path_b); ++} ++ ++ + static void property_update(GtkTreeStore *store, const GValue *value, + const char *key, connman_get_properties_reply callback) + { +- GSList *list, *link, *old_list, *new_list = NULL; ++ GSList *list, *link, *old_list, *new_list = NULL, *sorted_list = NULL; + const char *iface; + + DBG("store %p key %s", store, key); + +- if (g_str_equal(key, "Connections") == TRUE) +- iface = CONNMAN_CONNECTION_INTERFACE; +- else if (g_str_equal(key, "Devices") == TRUE) +- iface = CONNMAN_DEVICE_INTERFACE; +- else +- iface = CONNMAN_NETWORK_INTERFACE; ++ if (g_str_equal(key, "Services") == TRUE) ++ iface = CONNMAN_SERVICE_INTERFACE; + + old_list = g_object_get_data(G_OBJECT(store), key); + +@@ -180,7 +182,11 @@ static void property_update(GtkTreeStore *store, const GValue *value, + + g_object_set_data(G_OBJECT(store), key, new_list); + +- for (list = new_list; list; list = list->next) { ++ sorted_list = g_slist_sort_with_data(new_list, ++ (GCompareDataFunc)compare_list, store); ++ g_object_set_data(G_OBJECT(store), "Services", sorted_list); ++ ++ for (list = sorted_list; list; list = list->next) { + gchar *path = list->data; + DBusGProxy *proxy; + +@@ -205,25 +211,12 @@ static void property_update(GtkTreeStore *store, const GValue *value, + for (list = old_list; list; list = list->next) { + gchar *path = list->data; + GtkTreeIter iter; +- gchar *device = NULL; + + DBG("old path %s", path); + +- if (get_iter_from_path(store, &iter, path) == TRUE) { +- if (g_str_equal(key, "Connections") == TRUE) +- gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, +- CONNMAN_COLUMN_DEVICE, &device, -1); +- ++ if (get_iter_from_path(store, &iter, path) == TRUE) + gtk_tree_store_remove(store, &iter); +- } + +- if (get_iter_from_path(store, &iter, device) == TRUE) { +- gtk_tree_store_set(store, &iter, +- CONNMAN_COLUMN_INRANGE, FALSE, +- CONNMAN_COLUMN_ADDRESS, NULL, -1); +- } +- +- g_free(device); + g_free(path); + } + +@@ -263,48 +256,19 @@ static const gchar *type2icon(guint type) + return NULL; + } + +-static guint get_policy(const GValue *value) +-{ +- const char *policy = value ? g_value_get_string(value) : NULL; +- +- if (policy == NULL) +- return CONNMAN_POLICY_UNKNOWN; +- else if (g_str_equal(policy, "ignore") == TRUE) +- return CONNMAN_POLICY_IGNORE; +- else if (g_str_equal(policy, "off") == TRUE) +- return CONNMAN_POLICY_OFF; +- else if (g_str_equal(policy, "auto") == TRUE) +- return CONNMAN_POLICY_AUTO; +- else if (g_str_equal(policy, "manual") == TRUE) +- return CONNMAN_POLICY_MANUAL; +- +- return CONNMAN_POLICY_UNKNOWN; +-} +- +-static guint get_security(const GValue *value) +-{ +- const char *security = value ? g_value_get_string(value) : NULL; +- +- if (security == NULL) +- return CONNMAN_SECURITY_UNKNOWN; +- else if (g_str_equal(security, "none") == TRUE) +- return CONNMAN_SECURITY_NONE; +- else if (g_str_equal(security, "wep") == TRUE) +- return CONNMAN_SECURITY_WEP; +- else if (g_str_equal(security, "wpa") == TRUE) +- return CONNMAN_SECURITY_WPA; +- else if (g_str_equal(security, "wpa2") == TRUE) +- return CONNMAN_SECURITY_WPA2; +- +- return CONNMAN_SECURITY_UNKNOWN; +-} +- +-static void network_changed(DBusGProxy *proxy, const char *property, ++static void service_changed(DBusGProxy *proxy, const char *property, + GValue *value, gpointer user_data) + { + GtkTreeStore *store = user_data; + const char *path = dbus_g_proxy_get_path(proxy); + GtkTreeIter iter; ++ GHashTable *ipv4; ++ const gchar *method, *addr, *netmask, *gateway; ++ GValue *ipv4_method, *ipv4_address, *ipv4_netmask, *ipv4_gateway; ++ ++ const gchar *state, *icon, *name, *security, *passphrase; ++ guint strength, type; ++ + + DBG("store %p proxy %p property %s", store, proxy, property); + +@@ -314,141 +278,92 @@ static void network_changed(DBusGProxy *proxy, const char *property, + if (get_iter_from_path(store, &iter, path) == FALSE) + return; + +- if (g_str_equal(property, "Connected") == TRUE) { +- gboolean connected = g_value_get_boolean(value); +- gtk_tree_store_set(store, &iter, +- CONNMAN_COLUMN_ENABLED, connected, -1); +- } else if (g_str_equal(property, "Available") == TRUE) { +- gboolean inrange = g_value_get_boolean(value); +- gtk_tree_store_set(store, &iter, +- CONNMAN_COLUMN_INRANGE, inrange, -1); +- } else if (g_str_equal(property, "Remember") == TRUE) { +- gboolean remember = g_value_get_boolean(value); +- gtk_tree_store_set(store, &iter, +- CONNMAN_COLUMN_REMEMBER, remember, -1); +- } else if (g_str_equal(property, "Strength") == TRUE) { +- guint strength = g_value_get_uchar(value); +- gtk_tree_store_set(store, &iter, +- CONNMAN_COLUMN_STRENGTH, strength, -1); +- } +-} +- +-static void network_properties(DBusGProxy *proxy, GHashTable *hash, +- GError *error, gpointer user_data) +-{ +- GtkTreeStore *store = user_data; +- GValue *value; +- const gchar *device, *name, *secret; +- gboolean connected, inrange, remember; +- guint strength, security; +- GtkTreeIter iter, parent; +- +- DBG("store %p proxy %p hash %p", store, proxy, hash); +- +- if (error != NULL || hash == NULL) +- goto done; +- +- value = g_hash_table_lookup(hash, "Device"); +- device = value ? g_value_get_boxed(value) : NULL; ++ if (g_str_equal(property, "IPv4") == TRUE) { + +- value = g_hash_table_lookup(hash, "Name"); +- name = value ? g_value_get_string(value) : NULL; +- +- value = g_hash_table_lookup(hash, "Connected"); +- connected = value ? g_value_get_boolean(value) : FALSE; ++ ipv4 = g_value_get_boxed (value); ++ if (!ipv4) ++ return; + +- value = g_hash_table_lookup(hash, "Available"); +- inrange = value ? g_value_get_boolean(value) : FALSE; ++ ipv4_method = g_hash_table_lookup (ipv4, "Method"); ++ method = ipv4_method ? g_value_get_string(ipv4_method) : NULL; + +- value = g_hash_table_lookup(hash, "Remember"); +- remember = value ? g_value_get_boolean(value) : FALSE; ++ ipv4_address = g_hash_table_lookup (ipv4, "Address"); ++ addr = ipv4_address ? g_value_get_string(ipv4_address) : NULL; + +- value = g_hash_table_lookup(hash, "Strength"); +- strength = value ? g_value_get_uchar(value) : 0; ++ ipv4_netmask = g_hash_table_lookup (ipv4, "Netmask"); ++ netmask = ipv4_netmask ? g_value_get_string(ipv4_netmask) : NULL; + +- value = g_hash_table_lookup(hash, "WiFi.Security"); +- security = get_security(value); ++ ipv4_gateway = g_hash_table_lookup (ipv4, "Gateway"); ++ gateway = ipv4_gateway ? g_value_get_string(ipv4_gateway) : NULL; + +- value = g_hash_table_lookup(hash, "WiFi.Passphrase"); +- secret = value ? g_value_get_string(value) : NULL; +- +- DBG("name %s strength %d", name, strength); +- +- if (get_iter_from_path(store, &parent, device) == FALSE) +- return; +- +- if (get_iter_from_proxy(store, &iter, proxy) == FALSE) { +- gtk_tree_store_insert_with_values(store, &iter, &parent, -1, +- CONNMAN_COLUMN_PROXY, proxy, ++ gtk_tree_store_set(store, &iter, ++ CONNMAN_COLUMN_METHOD, method, ++ CONNMAN_COLUMN_ADDRESS, addr, ++ CONNMAN_COLUMN_NETMASK, netmask, ++ CONNMAN_COLUMN_GATEWAY, gateway, ++ -1); ++ ++ } else if (g_str_equal(property, "State") == TRUE) { ++ state = value ? g_value_get_string(value) : NULL; ++ gtk_tree_store_set(store, &iter, ++ CONNMAN_COLUMN_STATE, state, ++ -1); ++ } else if (g_str_equal(property, "Name") == TRUE) { ++ name = value ? g_value_get_string(value) : NULL; ++ gtk_tree_store_set(store, &iter, + CONNMAN_COLUMN_NAME, name, +- CONNMAN_COLUMN_ENABLED, connected, +- CONNMAN_COLUMN_INRANGE, inrange, +- CONNMAN_COLUMN_REMEMBER, remember, +- CONNMAN_COLUMN_STRENGTH, strength, ++ -1); ++ } else if (g_str_equal(property, "Type") == TRUE) { ++ type = get_type(value); ++ icon = type2icon(type); ++ gtk_tree_store_set(store, &iter, ++ CONNMAN_COLUMN_TYPE, type, ++ CONNMAN_COLUMN_ICON, icon, ++ -1); ++ } else if (g_str_equal(property, "Security") == TRUE) { ++ security = value ? g_value_get_string(value) : NULL; ++ gtk_tree_store_set(store, &iter, + CONNMAN_COLUMN_SECURITY, security, +- CONNMAN_COLUMN_PASSPHRASE, secret, -1); +- +- dbus_g_proxy_add_signal(proxy, "PropertyChanged", +- G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); +- dbus_g_proxy_connect_signal(proxy, "PropertyChanged", +- G_CALLBACK(network_changed), store, NULL); +- } else ++ -1); ++ } else if (g_str_equal(property, "PassPhrase") == TRUE) { ++ passphrase = value ? g_value_get_string(value) : NULL; ++ gtk_tree_store_set(store, &iter, ++ CONNMAN_COLUMN_PASSPHRASE, passphrase, ++ -1); ++ } else if (g_str_equal(property, "Strength") == TRUE) { ++ strength = value ? g_value_get_uchar(value) : 0; + gtk_tree_store_set(store, &iter, +- CONNMAN_COLUMN_NAME, name, +- CONNMAN_COLUMN_ENABLED, connected, +- CONNMAN_COLUMN_INRANGE, inrange, +- CONNMAN_COLUMN_REMEMBER, remember, + CONNMAN_COLUMN_STRENGTH, strength, +- CONNMAN_COLUMN_SECURITY, security, +- CONNMAN_COLUMN_PASSPHRASE, secret, -1); +- +-done: +- g_object_unref(proxy); ++ -1); ++ } + } + +-static void device_changed(DBusGProxy *proxy, const char *property, +- GValue *value, gpointer user_data) ++static void service_properties(DBusGProxy *proxy, GHashTable *hash, ++ GError *error, gpointer user_data) + { + GtkTreeStore *store = user_data; + const char *path = dbus_g_proxy_get_path(proxy); +- GtkTreeIter iter; + +- DBG("store %p proxy %p property %s", store, proxy, property); ++ const gchar *state, *icon, *name, *security, *passphrase; ++ guint strength, type; + +- if (property == NULL || value == NULL) +- return; +- +- if (get_iter_from_path(store, &iter, path) == FALSE) +- return; ++ GHashTable *ipv4; ++ GValue *ipv4_method, *ipv4_address, *ipv4_netmask, *ipv4_gateway; ++ const gchar *method, *addr, *netmask, *gateway; + +- if (g_str_equal(property, "Policy") == TRUE) { +- guint policy = get_policy(value); +- gtk_tree_store_set(store, &iter, +- CONNMAN_COLUMN_POLICY, policy, -1); +- } else if (g_str_equal(property, "Powered") == TRUE) { +- gboolean powered = g_value_get_boolean(value); +- gtk_tree_store_set(store, &iter, +- CONNMAN_COLUMN_ENABLED, powered, -1); +- } else if (g_str_equal(property, "Networks") == TRUE) +- property_update(store, value, path, network_properties); +-} ++ GtkTreeIter iter; + +-static void device_properties(DBusGProxy *proxy, GHashTable *hash, +- GError *error, gpointer user_data) +-{ +- GtkTreeStore *store = user_data; +- const char *path = dbus_g_proxy_get_path(proxy); + GValue *value; +- const gchar *name, *icon; +- guint type, policy; +- gboolean powered; +- GtkTreeIter iter; + + DBG("store %p proxy %p hash %p", store, proxy, hash); ++ DBG("path %s", path); + + if (error != NULL || hash == NULL) + goto done; + ++ value = g_hash_table_lookup(hash, "State"); ++ state = value ? g_value_get_string(value) : NULL; ++ + value = g_hash_table_lookup(hash, "Name"); + name = value ? g_value_get_string(value) : NULL; + +@@ -456,129 +371,69 @@ static void device_properties(DBusGProxy *proxy, GHashTable *hash, + type = get_type(value); + icon = type2icon(type); + +- value = g_hash_table_lookup(hash, "Policy"); +- policy = get_policy(value); +- +- value = g_hash_table_lookup(hash, "Powered"); +- powered = value ? g_value_get_boolean(value) : FALSE; +- +- DBG("name %s type %d icon %s", name, type, icon); ++ value = g_hash_table_lookup(hash, "Security"); ++ security = value ? g_value_get_string(value) : NULL; + +- if (get_iter_from_proxy(store, &iter, proxy) == FALSE) { +- gtk_tree_store_insert_with_values(store, &iter, NULL, -1, +- CONNMAN_COLUMN_PROXY, proxy, +- CONNMAN_COLUMN_NAME, name, +- CONNMAN_COLUMN_ICON, icon, +- CONNMAN_COLUMN_TYPE, type, +- CONNMAN_COLUMN_ENABLED, powered, +- CONNMAN_COLUMN_POLICY, policy, -1); +- +- dbus_g_proxy_add_signal(proxy, "PropertyChanged", +- G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); +- dbus_g_proxy_connect_signal(proxy, "PropertyChanged", +- G_CALLBACK(device_changed), store, NULL); +- } else +- gtk_tree_store_set(store, &iter, +- CONNMAN_COLUMN_NAME, name, +- CONNMAN_COLUMN_ICON, icon, +- CONNMAN_COLUMN_TYPE, type, +- CONNMAN_COLUMN_ENABLED, powered, +- CONNMAN_COLUMN_POLICY, policy, -1); +- +- value = g_hash_table_lookup(hash, "Networks"); +- if (value != NULL) +- property_update(store, value, path, network_properties); +- +-done: +- g_object_unref(proxy); +-} +- +-static void connection_changed(DBusGProxy *proxy, const char *property, +- GValue *value, gpointer user_data) +-{ +- GtkTreeStore *store = user_data; +- const char *path = dbus_g_proxy_get_path(proxy); +- GtkTreeIter iter; +- +- DBG("store %p proxy %p property %s", store, proxy, property); +- +- if (property == NULL || value == NULL) +- return; ++ value = g_hash_table_lookup(hash, "PassPhrase"); ++ passphrase = value ? g_value_get_string(value) : NULL; + +- if (get_iter_from_path(store, &iter, path) == FALSE) +- return; +- +- if (g_str_equal(property, "Default") == TRUE) { +- gboolean enabled = g_value_get_boolean(value); +- gtk_tree_store_set(store, &iter, +- CONNMAN_COLUMN_ENABLED, enabled, -1); +- } else if (g_str_equal(property, "Strength") == TRUE) { +- guint strength = g_value_get_uchar(value); +- gtk_tree_store_set(store, &iter, +- CONNMAN_COLUMN_STRENGTH, strength, -1); +- } +-} +- +-static void connection_properties(DBusGProxy *proxy, GHashTable *hash, +- GError *error, gpointer user_data) +-{ +- GtkTreeStore *store = user_data; +- GValue *value; +- guint type, strength; +- gboolean enabled; +- const char *device, *address; +- GtkTreeIter iter; ++ value = g_hash_table_lookup(hash, "Strength"); ++ strength = value ? g_value_get_uchar(value) : 0; + +- DBG("store %p proxy %p hash %p", store, proxy, hash); ++ value = g_hash_table_lookup(hash, "IPv4.Configuration"); ++ ipv4 = g_value_get_boxed (value); + +- if (error != NULL || hash == NULL) ++ if (!ipv4) + goto done; + +- value = g_hash_table_lookup(hash, "Type"); +- type = get_type(value); ++ ipv4_method = g_hash_table_lookup (ipv4, "Method"); ++ method = ipv4_method ? g_value_get_string(ipv4_method) : NULL; + +- value = g_hash_table_lookup(hash, "Strength"); +- strength = value ? g_value_get_uchar(value) : 0; ++ ipv4_address = g_hash_table_lookup (ipv4, "Address"); ++ addr = ipv4_address ? g_value_get_string(ipv4_address) : NULL; + +- value = g_hash_table_lookup(hash, "Default"); +- enabled = value ? g_value_get_boolean(value) : FALSE; ++ ipv4_netmask = g_hash_table_lookup (ipv4, "Netmask"); ++ netmask = ipv4_netmask ? g_value_get_string(ipv4_netmask) : NULL; + +- value = g_hash_table_lookup(hash, "IPv4.Address"); +- address = value ? g_value_get_string(value) : NULL; ++ ipv4_gateway = g_hash_table_lookup (ipv4, "Gateway"); ++ gateway = ipv4_gateway ? g_value_get_string(ipv4_gateway) : NULL; + +- DBG("type %d address %s", type, address); ++ DBG("name %s type %d icon %s state %s", name, type, icon, state); + + if (get_iter_from_proxy(store, &iter, proxy) == FALSE) { + gtk_tree_store_insert_with_values(store, &iter, NULL, -1, + CONNMAN_COLUMN_PROXY, proxy, ++ CONNMAN_COLUMN_NAME, name, ++ CONNMAN_COLUMN_ICON, icon, + CONNMAN_COLUMN_TYPE, type, +- CONNMAN_COLUMN_ENABLED, enabled, ++ CONNMAN_COLUMN_STATE, state, ++ CONNMAN_COLUMN_SECURITY, security, ++ CONNMAN_COLUMN_PASSPHRASE, passphrase, + CONNMAN_COLUMN_STRENGTH, strength, +- CONNMAN_COLUMN_ADDRESS, address, -1); ++ CONNMAN_COLUMN_METHOD, method, ++ CONNMAN_COLUMN_ADDRESS, addr, ++ CONNMAN_COLUMN_NETMASK, netmask, ++ CONNMAN_COLUMN_GATEWAY, gateway, ++ -1); + + dbus_g_proxy_add_signal(proxy, "PropertyChanged", + G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); + dbus_g_proxy_connect_signal(proxy, "PropertyChanged", +- G_CALLBACK(connection_changed), store, NULL); ++ G_CALLBACK(service_changed), store, NULL); + } else + gtk_tree_store_set(store, &iter, ++ CONNMAN_COLUMN_NAME, name, ++ CONNMAN_COLUMN_ICON, icon, + CONNMAN_COLUMN_TYPE, type, +- CONNMAN_COLUMN_ENABLED, enabled, +- CONNMAN_COLUMN_STRENGTH, strength, -1); +- +- value = g_hash_table_lookup(hash, "Device"); +- device = value ? g_value_get_boxed(value) : NULL; +- +- DBG("device %s", device); +- +- gtk_tree_store_set(store, &iter, CONNMAN_COLUMN_DEVICE, device, -1); +- +- if (get_iter_from_path(store, &iter, device) == TRUE) { +- gtk_tree_store_set(store, &iter, +- CONNMAN_COLUMN_DEVICE, device, +- CONNMAN_COLUMN_INRANGE, TRUE, +- CONNMAN_COLUMN_ADDRESS, address, -1); +- } ++ CONNMAN_COLUMN_STATE, state, ++ CONNMAN_COLUMN_SECURITY, security, ++ CONNMAN_COLUMN_PASSPHRASE, passphrase, ++ CONNMAN_COLUMN_STRENGTH, strength, ++ CONNMAN_COLUMN_METHOD, method, ++ CONNMAN_COLUMN_ADDRESS, addr, ++ CONNMAN_COLUMN_NETMASK, netmask, ++ CONNMAN_COLUMN_GATEWAY, gateway, ++ -1); + + done: + g_object_unref(proxy); +@@ -594,25 +449,8 @@ static void manager_changed(DBusGProxy *proxy, const char *property, + if (property == NULL || value == NULL) + return; + +- if (g_str_equal(property, "State") == TRUE) { +- ConnmanClientCallback callback; +- gpointer userdata; +- gchar *state; +- +- state = g_object_get_data(G_OBJECT(store), "State"); +- g_free(state); +- +- state = g_value_dup_string(value); +- g_object_set_data(G_OBJECT(store), "State", state); +- +- callback = g_object_get_data(G_OBJECT(store), "callback"); +- userdata = g_object_get_data(G_OBJECT(store), "userdata"); +- if (callback) +- callback(state, userdata); +- } else if (g_str_equal(property, "Connections") == TRUE) { +- property_update(store, value, property, connection_properties); +- } else if (g_str_equal(property, "Devices") == TRUE) { +- property_update(store, value, property, device_properties); ++ if (g_str_equal(property, "Services") == TRUE) { ++ property_update(store, value, property, service_properties); + } + } + +@@ -620,31 +458,16 @@ static void manager_properties(DBusGProxy *proxy, GHashTable *hash, + GError *error, gpointer user_data) + { + GtkTreeStore *store = user_data; +- ConnmanClientCallback callback; + GValue *value; +- gchar *state; + + DBG("store %p proxy %p hash %p", store, proxy, hash); + + if (error != NULL || hash == NULL) + return; + +- value = g_hash_table_lookup(hash, "State"); +- state = value ? g_value_dup_string(value) : NULL; +- g_object_set_data(G_OBJECT(store), "State", state); +- +- callback = g_object_get_data(G_OBJECT(store), "callback"); +- if (callback) +- callback(state, NULL); +- +- value = g_hash_table_lookup(hash, "Devices"); +- if (value != NULL) +- property_update(store, value, "Devices", device_properties); +- +- value = g_hash_table_lookup(hash, "Connections"); ++ value = g_hash_table_lookup(hash, "Services"); + if (value != NULL) +- property_update(store, value, +- "Connections", connection_properties); ++ property_update(store, value, "Services", service_properties); + } + + DBusGProxy *connman_dbus_create_manager(DBusGConnection *conn, +diff --git a/common/connman-dbus.h b/common/connman-dbus.h +index a9fa51c..47179da 100644 +--- a/common/connman-dbus.h ++++ b/common/connman-dbus.h +@@ -30,10 +30,10 @@ + #define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager" + #define CONNMAN_MANAGER_PATH "/" + +-#define CONNMAN_PROFILE_INTERFACE CONNMAN_SERVICE ".Profile" +-#define CONNMAN_DEVICE_INTERFACE CONNMAN_SERVICE ".Device" +-#define CONNMAN_NETWORK_INTERFACE CONNMAN_SERVICE ".Network" +-#define CONNMAN_CONNECTION_INTERFACE CONNMAN_SERVICE ".Connection" ++//#define CONNMAN_PROFILE_INTERFACE CONNMAN_SERVICE ".Profile" ++#define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service" ++//#define CONNMAN_NETWORK_INTERFACE CONNMAN_SERVICE ".Network" ++//#define CONNMAN_CONNECTION_INTERFACE CONNMAN_SERVICE ".Connection" + + DBusGProxy *connman_dbus_create_manager(DBusGConnection *connection, + GtkTreeStore *store); +diff --git a/common/demo.c b/common/demo.c +deleted file mode 100644 +index 5e3924f..0000000 +--- a/common/demo.c ++++ /dev/null +@@ -1,465 +0,0 @@ +-/* +- * +- * Connection Manager +- * +- * Copyright (C) 2008 Intel Corporation. All rights reserved. +- * +- * This program is free software; you can redistribute it and/or modify +- * it under the terms of the GNU General Public License version 2 as +- * published by the Free Software Foundation. +- * +- * This program is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +- * GNU General Public License for more details. +- * +- * You should have received a copy of the GNU General Public License +- * along with this program; if not, write to the Free Software +- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +- * +- */ +- +-#ifdef HAVE_CONFIG_H +-#include <config.h> +-#endif +- +-#include <dbus/dbus-glib.h> +-#include <gtk/gtk.h> +- +-#include "connman-client.h" +- +-static gboolean option_fullscreen = FALSE; +-static ConnmanClient *client; +- +-static GtkWidget *tree_networks = NULL; +-static GtkWidget *button_enabled = NULL; +-static GtkWidget *button_refresh = NULL; +-static GtkWidget *button_connect = NULL; +-static GtkWidget *label_status = NULL; +-static GtkTreeSelection *selection = NULL; +- +-static void status_callback(const char *status, void *user_data) +-{ +- gchar *markup; +- +- if (label_status == NULL) +- return; +- +- markup = g_strdup_printf("System is %s", status); +- gtk_label_set_markup(GTK_LABEL(label_status), markup); +- g_free(markup); +-} +- +-static GtkWidget *create_label(const gchar *str) +-{ +- GtkWidget *label; +- gchar *tmp; +- +- label = gtk_label_new(NULL); +- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); +- gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); +- +- tmp = g_strdup_printf("<b>%s</b>", str); +- gtk_label_set_markup(GTK_LABEL(label), tmp); +- g_free(tmp); +- +- return label; +-} +- +-static void changed_callback(GtkComboBox *combo, gpointer user_data) +-{ +- GtkTreeModel *model = gtk_combo_box_get_model(combo); +- GtkTreeIter iter; +- DBusGProxy *proxy; +- gchar *path; +- gboolean enabled; +- +- if (gtk_combo_box_get_active_iter(combo, &iter) == FALSE) +- return; +- +- path = g_object_get_data(G_OBJECT(button_enabled), "device"); +- g_free(path); +- +- gtk_tree_model_get(model, &iter, CONNMAN_COLUMN_PROXY, &proxy, +- CONNMAN_COLUMN_ENABLED, &enabled, -1); +- +- path = g_strdup(dbus_g_proxy_get_path(proxy)); +- g_object_set_data(G_OBJECT(button_enabled), "device", path); +- +- g_object_unref(proxy); +- +- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_enabled), +- enabled); +- +- gtk_widget_set_sensitive(button_refresh, enabled); +- +- model = connman_client_get_network_model(client, path); +- gtk_tree_view_set_model(GTK_TREE_VIEW(tree_networks), model); +- g_object_unref(model); +-} +- +-static void toggled_callback(GtkToggleButton *button, gpointer user_data) +-{ +- gchar *path; +- gboolean active; +- +- path = g_object_get_data(G_OBJECT(button), "device"); +- if (path == NULL) +- return; +- +- active = gtk_toggle_button_get_active(button); +- +- connman_client_set_powered(client, path, active); +- +- gtk_widget_set_sensitive(button_refresh, active); +-} +- +-static void refresh_callback(GtkButton *button, gpointer user_data) +-{ +- gchar *path; +- +- path = g_object_get_data(G_OBJECT(button_enabled), "device"); +- if (path == NULL) +- return; +- +- connman_client_propose_scan(client, path); +-} +- +-static void connect_callback(GtkButton *button, gpointer user_data) +-{ +- GtkTreeModel *model; +- GtkTreeIter iter; +- DBusGProxy *proxy; +- const gchar *path; +- gboolean enabled; +- +- if (gtk_tree_selection_get_selected(selection, &model, &iter) == FALSE) +- return; +- +- gtk_tree_model_get(model, &iter, CONNMAN_COLUMN_PROXY, &proxy, +- CONNMAN_COLUMN_ENABLED, &enabled, -1); +- +- path = dbus_g_proxy_get_path(proxy); +- +- if (enabled == FALSE) +- connman_client_connect(client, path); +- else +- connman_client_disconnect(client, path); +- +- g_object_unref(proxy); +- +- if (enabled == FALSE) +- g_object_set(button_connect, +- "label", GTK_STOCK_DISCONNECT, NULL); +- else +- g_object_set(button_connect, +- "label", GTK_STOCK_CONNECT, NULL); +-} +- +-static GtkWidget *create_left(void) +-{ +- GtkWidget *mainbox; +- GtkWidget *vbox; +- GtkWidget *hbox; +- GtkWidget *label; +- GtkWidget *combo; +- GtkWidget *button; +- GtkTreeModel *model; +- GtkCellRenderer *renderer; +- +- mainbox = gtk_vbox_new(FALSE, 24); +- gtk_container_set_border_width(GTK_CONTAINER(mainbox), 8); +- +- vbox = gtk_vbox_new(FALSE, 6); +- gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0); +- +- label = create_label("Device"); +- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); +- +- combo = gtk_combo_box_new(); +- gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 0); +- g_signal_connect(G_OBJECT(combo), "changed", +- G_CALLBACK(changed_callback), NULL); +- +- gtk_cell_layout_clear(GTK_CELL_LAYOUT(combo)); +- +- renderer = gtk_cell_renderer_text_new(); +- gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE); +- gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, +- "text", CONNMAN_COLUMN_NAME, NULL); +- +- button = gtk_check_button_new_with_label("Enabled"); +- gtk_box_pack_end(GTK_BOX(vbox), button, FALSE, FALSE, 0); +- g_signal_connect(G_OBJECT(button), "toggled", +- G_CALLBACK(toggled_callback), NULL); +- +- button_enabled = button; +- +- vbox = gtk_vbox_new(FALSE, 6); +- gtk_box_pack_start(GTK_BOX(mainbox), vbox, TRUE, TRUE, 0); +- +- label = create_label("Status"); +- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); +- +- label = gtk_label_new(NULL); +- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); +- gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); +- gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); +- +- label_status = label; +- +- vbox = gtk_vbox_new(FALSE, 6); +- gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0); +- +- hbox = gtk_hbox_new(FALSE, 12); +- gtk_box_set_homogeneous(GTK_BOX(hbox), TRUE); +- gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0); +- +- button = gtk_button_new_from_stock(GTK_STOCK_REFRESH); +- gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); +- gtk_widget_set_sensitive(button, FALSE); +- g_signal_connect(G_OBJECT(button), "clicked", +- G_CALLBACK(refresh_callback), NULL); +- +- button_refresh = button; +- +- button = gtk_button_new_from_stock(GTK_STOCK_DISCONNECT); +- gtk_box_pack_end(GTK_BOX(hbox), button, TRUE, TRUE, 0); +- gtk_widget_set_sensitive(button, FALSE); +- g_signal_connect(G_OBJECT(button), "clicked", +- G_CALLBACK(connect_callback), NULL); +- +- button_connect = button; +- +- model = connman_client_get_device_model(client); +- gtk_combo_box_set_model(GTK_COMBO_BOX(combo), model); +- g_object_unref(model); +- +- gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); +- +- return mainbox; +-} +- +-static void select_callback(GtkTreeSelection *selection, gpointer user_data) +-{ +- GtkTreeModel *model; +- GtkTreeIter iter; +- gboolean selected, enabled; +- +- selected = gtk_tree_selection_get_selected(selection, &model, &iter); +- +- if (selected == TRUE) { +- gtk_tree_model_get(model, &iter, +- CONNMAN_COLUMN_ENABLED, &enabled, -1); +- +- if (enabled == TRUE) +- g_object_set(button_connect, +- "label", GTK_STOCK_DISCONNECT, NULL); +- else +- g_object_set(button_connect, +- "label", GTK_STOCK_CONNECT, NULL); +- } +- +- gtk_widget_set_sensitive(button_connect, selected); +-} +- +-static void status_to_icon(GtkTreeViewColumn *column, GtkCellRenderer *cell, +- GtkTreeModel *model, GtkTreeIter *iter, gpointer data) +-{ +- gboolean enabled; +- +- gtk_tree_model_get(model, iter, CONNMAN_COLUMN_ENABLED, &enabled, -1); +- +- if (enabled == TRUE) +- g_object_set(cell, "icon-name", GTK_STOCK_ABOUT, NULL); +- +- g_object_set(cell, "visible", enabled, NULL); +-} +- +-static void security_to_icon(GtkTreeViewColumn *column, GtkCellRenderer *cell, +- GtkTreeModel *model, GtkTreeIter *iter, gpointer data) +-{ +- guint security; +- +- gtk_tree_model_get(model, iter, CONNMAN_COLUMN_SECURITY, &security, -1); +- +- if (security == CONNMAN_SECURITY_NONE) +- g_object_set(cell, "icon-name", NULL, NULL); +- else +- g_object_set(cell, "icon-name", +- GTK_STOCK_DIALOG_AUTHENTICATION, NULL); +-} +- +-static GtkWidget *create_right(void) +-{ +- GtkWidget *mainbox; +- GtkWidget *vbox; +- GtkWidget *label; +- GtkWidget *scrolled; +- GtkWidget *tree; +- GtkTreeViewColumn *column; +- GtkCellRenderer *renderer; +- +- mainbox = gtk_vbox_new(FALSE, 24); +- gtk_container_set_border_width(GTK_CONTAINER(mainbox), 8); +- +- vbox = gtk_vbox_new(FALSE, 6); +- gtk_box_pack_start(GTK_BOX(mainbox), vbox, TRUE, TRUE, 0); +- +- label = create_label("Networks"); +- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); +- +- scrolled = gtk_scrolled_window_new(NULL, NULL); +- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), +- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); +- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), +- GTK_SHADOW_OUT); +- gtk_container_add(GTK_CONTAINER(vbox), scrolled); +- +- tree = gtk_tree_view_new(); +- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE); +- gtk_tree_view_set_show_expanders(GTK_TREE_VIEW(tree), FALSE); +- gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree), TRUE); +- gtk_container_add(GTK_CONTAINER(scrolled), tree); +- +- gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(tree), 0, +- NULL, gtk_cell_renderer_pixbuf_new(), +- status_to_icon, NULL, NULL); +- column = gtk_tree_view_get_column(GTK_TREE_VIEW(tree), 0); +- gtk_tree_view_column_set_min_width(column, 24); +- +- column = gtk_tree_view_column_new(); +- gtk_tree_view_column_set_expand(GTK_TREE_VIEW_COLUMN(column), TRUE); +- gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); +- +- renderer = gtk_cell_renderer_text_new(); +- gtk_tree_view_column_pack_start(column, renderer, TRUE); +- gtk_tree_view_column_add_attribute(column, renderer, +- "text", CONNMAN_COLUMN_NAME); +- +- renderer = gtk_cell_renderer_pixbuf_new(); +- gtk_tree_view_column_pack_end(column, renderer, FALSE); +- gtk_tree_view_column_set_cell_data_func(column, renderer, +- security_to_icon, NULL, NULL); +- +- tree_networks = tree; +- +- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); +- gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); +- g_signal_connect(G_OBJECT(selection), "changed", +- G_CALLBACK(select_callback), NULL); +- +- return mainbox; +-} +- +-static gboolean delete_callback(GtkWidget *window, GdkEvent *event, +- gpointer user_data) +-{ +- gtk_widget_destroy(window); +- +- gtk_main_quit(); +- +- return FALSE; +-} +- +-static void close_callback(GtkWidget *button, gpointer user_data) +-{ +- GtkWidget *window = user_data; +- +- gtk_widget_destroy(window); +- +- gtk_main_quit(); +-} +- +-static GtkWidget *create_window(void) +-{ +- GtkWidget *window; +- GtkWidget *vbox; +- GtkWidget *hbox; +- GtkWidget *notebook; +- GtkWidget *buttonbox; +- GtkWidget *button; +- GtkWidget *widget; +- +- window = gtk_window_new(GTK_WINDOW_TOPLEVEL); +- gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); +- gtk_window_set_default_size(GTK_WINDOW(window), 580, 360); +- g_signal_connect(G_OBJECT(window), "delete-event", +- G_CALLBACK(delete_callback), NULL); +- +- vbox = gtk_vbox_new(FALSE, 12); +- gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); +- gtk_container_add(GTK_CONTAINER(window), vbox); +- +- notebook = gtk_notebook_new(); +- gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE); +- gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); +- +- buttonbox = gtk_hbutton_box_new(); +- gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonbox), GTK_BUTTONBOX_END); +- gtk_box_pack_start(GTK_BOX(vbox), buttonbox, FALSE, FALSE, 0); +- +- button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); +- gtk_container_add(GTK_CONTAINER(buttonbox), button); +- g_signal_connect(G_OBJECT(button), "clicked", +- G_CALLBACK(close_callback), window); +- +- hbox = gtk_hbox_new(FALSE, 0); +- gtk_container_set_border_width(GTK_CONTAINER(hbox), 8); +- +- widget = create_right(); +- gtk_widget_set_size_request(widget, 280, -1); +- gtk_box_pack_end(GTK_BOX(hbox), widget, TRUE, TRUE, 0); +- +- widget = create_left(); +- gtk_widget_set_size_request(widget, 260, -1); +- gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); +- +- gtk_notebook_append_page(GTK_NOTEBOOK(notebook), hbox, NULL); +- +- return window; +-} +- +-static GOptionEntry options[] = { +- { "fullscreen", 'f', 0, G_OPTION_ARG_NONE, &option_fullscreen, +- "Start up in fullscreen mode" }, +- { NULL }, +-}; +- +-int main(int argc, char *argv[]) +-{ +- GError *error = NULL; +- GtkWidget *window; +- +- if (gtk_init_with_args(&argc, &argv, NULL, +- options, NULL, &error) == FALSE) { +- if (error != NULL) { +- g_printerr("%s\n", error->message); +- g_error_free(error); +- } else +- g_printerr("An unknown error occurred\n"); +- +- gtk_exit(1); +- } +- +- g_set_application_name("Connection Manager Demo"); +- +- gtk_window_set_default_icon_name("network-wireless"); +- +- client = connman_client_new(); +- +- window = create_window(); +- +- connman_client_set_callback(client, status_callback, NULL); +- +- if (option_fullscreen == TRUE) +- gtk_window_fullscreen(GTK_WINDOW(window)); +- +- gtk_widget_show_all(window); +- +- gtk_main(); +- +- g_object_unref(client); +- +- return 0; +-} +diff --git a/common/test-client.c b/common/test-client.c +deleted file mode 100644 +index a78823f..0000000 +--- a/common/test-client.c ++++ /dev/null +@@ -1,227 +0,0 @@ +-/* +- * +- * Connection Manager +- * +- * Copyright (C) 2008 Intel Corporation. All rights reserved. +- * +- * This program is free software; you can redistribute it and/or modify +- * it under the terms of the GNU General Public License version 2 as +- * published by the Free Software Foundation. +- * +- * This program is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +- * GNU General Public License for more details. +- * +- * You should have received a copy of the GNU General Public License +- * along with this program; if not, write to the Free Software +- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +- * +- */ +- +-#ifdef HAVE_CONFIG_H +-#include <config.h> +-#endif +- +-#include <dbus/dbus-glib.h> +-#include <gtk/gtk.h> +- +-#include "connman-client.h" +- +-static ConnmanClient *client; +- +-static void proxy_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell, +- GtkTreeModel *model, GtkTreeIter *iter, gpointer data) +-{ +- DBusGProxy *proxy; +- gchar *markup; +- +- gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy, -1); +- +- markup = g_strdup_printf("<b>%s</b>\n" +- "<span size=\"xx-small\">%s\n\n</span>", +- dbus_g_proxy_get_interface(proxy), +- dbus_g_proxy_get_path(proxy)); +- g_object_set(cell, "markup", markup, NULL); +- g_free(markup); +- +- g_object_unref(proxy); +-} +- +-static void name_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell, +- GtkTreeModel *model, GtkTreeIter *iter, gpointer data) +-{ +- gchar *name, *icon; +- guint type; +- gchar *markup; +- +- gtk_tree_model_get(model, iter, CONNMAN_COLUMN_NAME, &name, +- CONNMAN_COLUMN_ICON, &icon, +- CONNMAN_COLUMN_TYPE, &type, -1); +- +- markup = g_strdup_printf("Name: %s\nIcon: %s\nType: %d", +- name, icon, type); +- g_object_set(cell, "markup", markup, NULL); +- g_free(markup); +- +- g_free(icon); +- g_free(name); +-} +- +-static void status_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell, +- GtkTreeModel *model, GtkTreeIter *iter, gpointer data) +-{ +- gboolean enabled, inrange, remember; +- gchar *markup; +- +- gtk_tree_model_get(model, iter, CONNMAN_COLUMN_ENABLED, &enabled, +- CONNMAN_COLUMN_INRANGE, &inrange, +- CONNMAN_COLUMN_REMEMBER, &remember, -1); +- +- markup = g_strdup_printf("Enabled: %d\n" +- "InRange: %d\nRemember: %d", +- enabled, inrange, remember); +- g_object_set(cell, "markup", markup, NULL); +- g_free(markup); +-} +- +-static void network_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell, +- GtkTreeModel *model, GtkTreeIter *iter, gpointer data) +-{ +- guint strength, security; +- gchar *secret; +- gchar *markup; +- +- gtk_tree_model_get(model, iter, CONNMAN_COLUMN_STRENGTH, &strength, +- CONNMAN_COLUMN_SECURITY, &security, +- CONNMAN_COLUMN_PASSPHRASE, &secret, -1); +- +- markup = g_strdup_printf("Strength: %d\nSecurity: %d\nSecret: %s", +- strength, security, secret); +- g_object_set(cell, "markup", markup, NULL); +- g_free(markup); +- +- g_free(secret); +-} +- +-static GtkWidget *create_tree(void) +-{ +- GtkWidget *tree; +- GtkTreeModel *model; +- GtkTreeSelection *selection; +- +- tree = gtk_tree_view_new(); +- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), TRUE); +- gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree), TRUE); +- +- gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(tree), -1, +- "Proxy", gtk_cell_renderer_text_new(), +- proxy_to_text, NULL, NULL); +- +- gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(tree), -1, +- "Name", gtk_cell_renderer_text_new(), +- name_to_text, NULL, NULL); +- +- gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(tree), -1, +- "Status", gtk_cell_renderer_text_new(), +- status_to_text, NULL, NULL); +- +- gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(tree), -1, +- "Network", gtk_cell_renderer_text_new(), +- network_to_text, NULL, NULL); +- +- model = connman_client_get_model(client); +- gtk_tree_view_set_model(GTK_TREE_VIEW(tree), model); +- g_object_unref(model); +- +- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); +- gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); +- +- gtk_tree_view_expand_all(GTK_TREE_VIEW(tree)); +- +- return tree; +-} +- +-static gboolean delete_callback(GtkWidget *window, GdkEvent *event, +- gpointer user_data) +-{ +- gtk_widget_destroy(window); +- +- gtk_main_quit(); +- +- return FALSE; +-} +- +-static void close_callback(GtkWidget *button, gpointer user_data) +-{ +- GtkWidget *window = user_data; +- +- gtk_widget_destroy(window); +- +- gtk_main_quit(); +-} +- +-static GtkWidget *create_window(void) +-{ +- GtkWidget *window; +- GtkWidget *mainbox; +- GtkWidget *tree; +- GtkWidget *scrolled; +- GtkWidget *buttonbox; +- GtkWidget *button; +- GtkTreeSelection *selection; +- +- tree = create_tree(); +- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); +- +- window = gtk_window_new(GTK_WINDOW_TOPLEVEL); +- gtk_window_set_title(GTK_WINDOW(window), "Client Test"); +- gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); +- gtk_window_set_default_size(GTK_WINDOW(window), 800, 600); +- g_signal_connect(G_OBJECT(window), "delete-event", +- G_CALLBACK(delete_callback), NULL); +- +- mainbox = gtk_vbox_new(FALSE, 12); +- gtk_container_set_border_width(GTK_CONTAINER(mainbox), 12); +- gtk_container_add(GTK_CONTAINER(window), mainbox); +- +- scrolled = gtk_scrolled_window_new(NULL, NULL); +- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), +- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); +- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), +- GTK_SHADOW_OUT); +- gtk_box_pack_start(GTK_BOX(mainbox), scrolled, TRUE, TRUE, 0); +- +- buttonbox = gtk_hbutton_box_new(); +- gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonbox), +- GTK_BUTTONBOX_END); +- gtk_box_pack_end(GTK_BOX(mainbox), buttonbox, FALSE, FALSE, 0); +- +- button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); +- gtk_container_add(GTK_CONTAINER(buttonbox), button); +- g_signal_connect(G_OBJECT(button), "clicked", +- G_CALLBACK(close_callback), window); +- +- gtk_container_add(GTK_CONTAINER(scrolled), tree); +- +- gtk_widget_show_all(window); +- +- return window; +-} +- +-int main(int argc, char *argv[]) +-{ +- gtk_init(&argc, &argv); +- +- client = connman_client_new(); +- +- gtk_window_set_default_icon_name("network-wireless"); +- +- create_window(); +- +- gtk_main(); +- +- g_object_unref(client); +- +- return 0; +-} +diff --git a/properties/Makefile.am b/properties/Makefile.am +index ad2fd35..3a47ccf 100644 +--- a/properties/Makefile.am ++++ b/properties/Makefile.am +@@ -1,8 +1,7 @@ + + bin_PROGRAMS = connman-properties + +-connman_properties_SOURCES = main.c advanced.h advanced.c \ +- ethernet.c wifi.c ++connman_properties_SOURCES = main.c advanced.h ethernet.c wifi.c + + connman_properties_LDADD = $(top_builddir)/common/libcommon.a \ + @GTK_LIBS@ @DBUS_LIBS@ +diff --git a/properties/advanced.c b/properties/advanced.c +deleted file mode 100644 +index 1eb1c3d..0000000 +--- a/properties/advanced.c ++++ /dev/null +@@ -1,314 +0,0 @@ +-/* +- * +- * Connection Manager +- * +- * Copyright (C) 2008 Intel Corporation. All rights reserved. +- * +- * This program is free software; you can redistribute it and/or modify +- * it under the terms of the GNU General Public License version 2 as +- * published by the Free Software Foundation. +- * +- * This program is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +- * GNU General Public License for more details. +- * +- * You should have received a copy of the GNU General Public License +- * along with this program; if not, write to the Free Software +- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +- * +- */ +- +-#ifdef HAVE_CONFIG_H +-#include <config.h> +-#endif +- +-#include <dbus/dbus-glib.h> +-#include <glib/gi18n.h> +- +-#include "connman-client.h" +- +-#include "advanced.h" +- +-gboolean separator_function(GtkTreeModel *model, +- GtkTreeIter *iter, gpointer user_data) +-{ +- gchar *text; +- gboolean result = FALSE; +- +- gtk_tree_model_get(model, iter, 0, &text, -1); +- +- if (text && *text == '\0') +- result = TRUE; +- +- g_free(text); +- +- return result; +-} +- +-static void activate_callback(GtkWidget *button, gpointer user_data) +-{ +-} +- +-static void changed_callback(GtkWidget *editable, gpointer user_data) +-{ +-} +- +-static void add_network(GtkWidget *mainbox, struct config_data *data) +-{ +- GtkWidget *table; +- GtkWidget *label; +- GtkWidget *entry; +- GtkWidget *combo; +- GtkWidget *button; +- +- table = gtk_table_new(3, 5, TRUE); +- gtk_table_set_row_spacings(GTK_TABLE(table), 2); +- gtk_table_set_col_spacings(GTK_TABLE(table), 8); +- gtk_box_pack_start(GTK_BOX(mainbox), table, FALSE, FALSE, 0); +- +- label = gtk_label_new(_("Network Name:")); +- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); +- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); +- gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); +- +- combo = gtk_combo_box_entry_new_text(); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Guest"); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), ""); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Off"); +- gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(combo), +- separator_function, NULL, NULL); +- gtk_table_attach_defaults(GTK_TABLE(table), combo, 1, 3, 0, 1); +- //data->network.name = combo; +- +- label = gtk_label_new(_("Passphrase:")); +- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); +- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); +- gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); +- +- entry = gtk_entry_new(); +- gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); +- gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 3, 1, 2); +- //data->network.passphrase = entry; +- +- button = gtk_button_new_with_label(_("Activate")); +- gtk_widget_set_sensitive(button, FALSE); +- gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 2, 3); +- //data->network.activate = button; +- +- g_signal_connect(G_OBJECT(combo), "changed", +- G_CALLBACK(changed_callback), data); +- +- g_signal_connect(G_OBJECT(button), "clicked", +- G_CALLBACK(activate_callback), data); +-} +- +-static void set_widgets(struct config_data *data, gboolean label, +- gboolean value, gboolean entry) +-{ +- int i; +- +- for (i = 0; i < 3; i++) { +- if (label == TRUE) +- gtk_widget_show(data->ipv4.label[i]); +- else +- gtk_widget_hide(data->ipv4.label[i]); +- +- if (value == TRUE) +- gtk_widget_show(data->ipv4.value[i]); +- else +- gtk_widget_hide(data->ipv4.value[i]); +- +- if (entry == TRUE) +- gtk_widget_show(data->ipv4.entry[i]); +- else +- gtk_widget_hide(data->ipv4.entry[i]); +- } +-} +- +-static void config_callback(GtkWidget *widget, gpointer user_data) +-{ +- gint active; +- +- active = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); +-} +- +-static void add_config(GtkWidget *mainbox, struct config_data *data) +-{ +- GtkWidget *table; +- GtkWidget *label; +- GtkWidget *entry; +- GtkWidget *combo; +- +- table = gtk_table_new(5, 5, TRUE); +- gtk_table_set_row_spacings(GTK_TABLE(table), 2); +- gtk_table_set_col_spacings(GTK_TABLE(table), 8); +- gtk_box_pack_start(GTK_BOX(mainbox), table, FALSE, FALSE, 0); +- +- label = gtk_label_new(_("Configure IPv4:")); +- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); +- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); +- gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); +- +- combo = gtk_combo_box_new_text(); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Using DHCP"); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Manually"); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), ""); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Off"); +- gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(combo), +- separator_function, NULL, NULL); +- gtk_table_attach_defaults(GTK_TABLE(table), combo, 1, 3, 0, 1); +- data->ipv4.config = combo; +- +- label = gtk_label_new(_("IP Address:")); +- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); +- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); +- gtk_widget_set_no_show_all(label, TRUE); +- gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); +- data->ipv4.label[0] = label; +- +- label = gtk_label_new(NULL); +- gtk_label_set_selectable(GTK_LABEL(label), TRUE); +- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); +- gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +- gtk_widget_set_no_show_all(label, TRUE); +- gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 3, 1, 2); +- data->ipv4.value[0] = label; +- +- entry = gtk_entry_new(); +- gtk_widget_set_no_show_all(entry, TRUE); +- gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 3, 1, 2); +- data->ipv4.entry[0] = entry; +- +- label = gtk_label_new(_("Subnet Mask:")); +- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); +- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); +- gtk_widget_set_no_show_all(label, TRUE); +- gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); +- data->ipv4.label[1] = label; +- +- label = gtk_label_new(NULL); +- gtk_label_set_selectable(GTK_LABEL(label), TRUE); +- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); +- gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +- gtk_widget_set_no_show_all(label, TRUE); +- gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 3, 2, 3); +- data->ipv4.value[1] = label; +- +- entry = gtk_entry_new(); +- gtk_widget_set_no_show_all(entry, TRUE); +- gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 3, 2, 3); +- data->ipv4.entry[1] = entry; +- +- label = gtk_label_new(_("Router:")); +- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); +- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); +- gtk_widget_set_no_show_all(label, TRUE); +- gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); +- data->ipv4.label[2] = label; +- +- label = gtk_label_new(NULL); +- gtk_label_set_selectable(GTK_LABEL(label), TRUE); +- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); +- gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); +- gtk_widget_set_no_show_all(label, TRUE); +- gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 3, 3, 4); +- data->ipv4.value[2] = label; +- +- entry = gtk_entry_new(); +- gtk_widget_set_no_show_all(entry, TRUE); +- gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 3, 3, 4); +- data->ipv4.entry[2] = entry; +- +- gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); +- set_widgets(data, TRUE, TRUE, FALSE); +- +- g_signal_connect(G_OBJECT(combo), "changed", +- G_CALLBACK(config_callback), data); +-} +- +-static void delete_callback(GtkWidget *window, GdkEvent *event, +- gpointer user_data) +-{ +- gtk_widget_hide(window); +-} +- +-static void close_callback(GtkWidget *button, gpointer user_data) +-{ +- GtkWidget *window = user_data; +- +- gtk_widget_hide(window); +-} +- +-void create_advanced_dialog(struct config_data *data, guint type) +-{ +- GtkWidget *dialog; +- GtkWidget *vbox; +- GtkWidget *notebook; +- GtkWidget *buttonbox; +- GtkWidget *button; +- GtkWidget *widget; +- +- dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); +- gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); +- gtk_window_set_transient_for(GTK_WINDOW(dialog), +- GTK_WINDOW(data->window)); +- gtk_window_set_title(GTK_WINDOW(dialog), _("Advanced Settings")); +- gtk_window_set_position(GTK_WINDOW(dialog), +- GTK_WIN_POS_CENTER_ON_PARENT); +- gtk_window_set_default_size(GTK_WINDOW(dialog), 460, 320); +- g_signal_connect(G_OBJECT(dialog), "delete-event", +- G_CALLBACK(delete_callback), NULL); +- +- vbox = gtk_vbox_new(FALSE, 12); +- gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); +- gtk_container_add(GTK_CONTAINER(dialog), vbox); +- +- notebook = gtk_notebook_new(); +- gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); +- +- buttonbox = gtk_hbutton_box_new(); +- gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonbox), GTK_BUTTONBOX_END); +- gtk_box_set_spacing(GTK_BOX(buttonbox), 6); +- gtk_box_pack_start(GTK_BOX(vbox), buttonbox, FALSE, FALSE, 0); +- +- button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); +- gtk_container_add(GTK_CONTAINER(buttonbox), button); +- g_signal_connect(G_OBJECT(button), "clicked", +- G_CALLBACK(close_callback), dialog); +- +- button = gtk_button_new_from_stock(GTK_STOCK_OK); +- gtk_container_add(GTK_CONTAINER(buttonbox), button); +- g_signal_connect(G_OBJECT(button), "clicked", +- G_CALLBACK(close_callback), dialog); +- +- if (type == CONNMAN_TYPE_WIFI) { +- widget = gtk_vbox_new(FALSE, 24); +- gtk_container_set_border_width(GTK_CONTAINER(widget), 24); +- gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, NULL); +- gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(notebook), +- widget, _("Wireless")); +- add_network(widget, data); +- } +- +- widget = gtk_vbox_new(FALSE, 24); +- gtk_container_set_border_width(GTK_CONTAINER(widget), 24); +- gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, NULL); +- gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(notebook), +- widget, _("TCP/IP")); +- add_config(widget, data); +- +- widget = gtk_label_new(NULL); +- gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, NULL); +- gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(notebook), +- widget, _("DNS")); +- +- if (type == CONNMAN_TYPE_ETHERNET) { +- widget = gtk_label_new(NULL); +- gtk_notebook_append_page(GTK_NOTEBOOK(notebook), widget, NULL); +- gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(notebook), +- widget, _("Ethernet")); +- } +- +- data->dialog = dialog; +-} +diff --git a/properties/advanced.h b/properties/advanced.h +index f85f10d..a180b98 100644 +--- a/properties/advanced.h ++++ b/properties/advanced.h +@@ -23,6 +23,7 @@ struct config_data { + ConnmanClient *client; + + GtkWidget *widget; ++ GtkWidget *table; + GtkWidget *title; + GtkWidget *label; + GtkWidget *button; +@@ -45,15 +46,26 @@ struct config_data { + GtkWidget *value[3]; + GtkWidget *entry[3]; + } ipv4; ++ ++ struct ipv4_config ipv4_config; ++ ++ struct { ++ GtkWidget *name; ++ GtkWidget *security; ++ GtkWidget *strength; ++ GtkWidget *passphrase; ++ GtkWidget *connect_info; ++ GtkWidget *connect; ++ GtkWidget *disconnect; ++ } wifi; ++ ++ gboolean connecting; + }; + + void create_advanced_dialog(struct config_data *data, guint type); + +-void add_ethernet_policy(GtkWidget *mainbox, struct config_data *data); +-void update_ethernet_policy(struct config_data *data, guint policy); ++void add_ethernet_policy(GtkWidget *mainbox, GtkTreeIter *iter, struct config_data *data); ++void update_ethernet_ipv4(struct config_data *data, guint policy); + +-void add_wifi_policy(GtkWidget *mainbox, struct config_data *data); ++void add_wifi_policy(GtkWidget *mainbox, GtkTreeIter *iter, struct config_data *data); + void update_wifi_policy(struct config_data *data, guint policy); +- +-gboolean separator_function(GtkTreeModel *model, +- GtkTreeIter *iter, gpointer user_data); +diff --git a/properties/ethernet.c b/properties/ethernet.c +index d5c948d..1901ee6 100644 +--- a/properties/ethernet.c ++++ b/properties/ethernet.c +@@ -23,6 +23,7 @@ + #include <config.h> + #endif + ++#include <dbus/dbus-glib.h> + #include <glib/gi18n.h> + #include <gtk/gtk.h> + +@@ -30,93 +31,167 @@ + + #include "advanced.h" + ++static gboolean separator_function(GtkTreeModel *model, ++ GtkTreeIter *iter, gpointer user_data) ++{ ++ gchar *text; ++ gboolean result = FALSE; ++ ++ gtk_tree_model_get(model, iter, 0, &text, -1); ++ ++ if (text && *text == '\0') ++ result = TRUE; ++ ++ g_free(text); ++ ++ return result; ++} ++ + static void changed_callback(GtkWidget *editable, gpointer user_data) + { + struct config_data *data = user_data; + gint active; + + active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->policy.config)); ++ update_ethernet_ipv4(data, active); ++} + +- switch (active) { +- case 0: +- connman_client_set_policy(data->client, data->device, "auto"); +- update_ethernet_policy(data, CONNMAN_POLICY_AUTO); +- break; +- case 1: +- connman_client_set_policy(data->client, data->device, "ignore"); +- update_ethernet_policy(data, CONNMAN_POLICY_IGNORE); +- break; +- case 3: +- connman_client_set_policy(data->client, data->device, "off"); +- update_ethernet_policy(data, CONNMAN_POLICY_OFF); +- break; +- } ++static void apply_callback(GtkWidget *editable, gpointer user_data) ++{ ++ struct config_data *data = user_data; ++ gint active; ++ ++ active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->policy.config)); ++ data->ipv4_config.method = active ? "manual" : "dhcp"; ++ data->ipv4_config.address = active ? gtk_entry_get_text(GTK_ENTRY(data->ipv4.entry[0])) : NULL; ++ data->ipv4_config.netmask = active ? gtk_entry_get_text(GTK_ENTRY(data->ipv4.entry[1])) : NULL; ++ data->ipv4_config.gateway = active ? gtk_entry_get_text(GTK_ENTRY(data->ipv4.entry[2])) : NULL; ++ ++ connman_client_set_ipv4(data->client, data->device, &data->ipv4_config); + } + +-void add_ethernet_policy(GtkWidget *mainbox, struct config_data *data) ++void add_ethernet_policy(GtkWidget *mainbox, GtkTreeIter *iter, struct config_data *data) + { + GtkWidget *vbox; + GtkWidget *table; + GtkWidget *label; + GtkWidget *combo; +- +- vbox = gtk_vbox_new(FALSE, 0); ++ GtkWidget *entry; ++ GtkWidget *button; ++ ++ struct ipv4_config ipv4_config = { ++ .method = NULL, ++ .address = NULL, ++ .netmask = NULL, ++ .gateway = NULL, ++ }; ++ ++ gtk_tree_model_get(data->model, iter, ++ CONNMAN_COLUMN_METHOD, &ipv4_config.method, ++ CONNMAN_COLUMN_ADDRESS, &ipv4_config.address, ++ CONNMAN_COLUMN_NETMASK, &ipv4_config.netmask, ++ CONNMAN_COLUMN_GATEWAY, &ipv4_config.gateway, ++ -1); ++ ++ vbox = gtk_vbox_new(TRUE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 24); + gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0); + +- table = gtk_table_new(2, 4, FALSE); +- gtk_table_set_row_spacings(GTK_TABLE(table), 8); +- gtk_table_set_col_spacings(GTK_TABLE(table), 8); ++ table = gtk_table_new(5, 5, TRUE); ++ gtk_table_set_row_spacings(GTK_TABLE(table), 10); ++ gtk_table_set_col_spacings(GTK_TABLE(table), 10); + gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); + + label = gtk_label_new(_("Configuration:")); +- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); +- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); +- gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); ++ gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1); + + combo = gtk_combo_box_new_text(); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Automatically"); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Ignore Interface"); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), ""); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Off"); ++ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "DHCP"); ++ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Manual"); + gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(combo), +- separator_function, NULL, NULL); +- gtk_table_attach_defaults(GTK_TABLE(table), combo, 1, 4, 0, 1); ++ separator_function, NULL, NULL); ++ ++ gtk_table_attach_defaults(GTK_TABLE(table), combo, 2, 4, 0, 1); + data->policy.config = combo; + +- label = gtk_label_new(NULL); +- gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); +- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); +- gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); +- gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 4, 1, 2); +- gtk_widget_set_size_request(label, 180, -1); +- data->policy.label = label; ++ label = gtk_label_new(_("IP address:")); ++ gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); ++ data->ipv4.label[0] = label; ++ ++ entry = gtk_entry_new(); ++ gtk_entry_set_max_length (GTK_ENTRY (entry), 15); ++ if (ipv4_config.address) ++ gtk_entry_set_text(GTK_ENTRY(entry), ipv4_config.address); ++ gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 4, 1, 2); ++ data->ipv4.entry[0] = entry; ++ ++ label = gtk_label_new(_("Netmask:")); ++ gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3); ++ data->ipv4.label[1] = label; ++ ++ entry = gtk_entry_new(); ++ gtk_entry_set_max_length (GTK_ENTRY (entry), 15); ++ if (ipv4_config.netmask) ++ gtk_entry_set_text(GTK_ENTRY(entry), ipv4_config.netmask); ++ gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 4, 2, 3); ++ data->ipv4.entry[1] = entry; ++ ++ label = gtk_label_new(_("Gateway:")); ++ gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 3, 4); ++ data->ipv4.label[2] = label; ++ ++ entry = gtk_entry_new(); ++ gtk_entry_set_max_length (GTK_ENTRY (entry), 15); ++ if (ipv4_config.gateway) ++ gtk_entry_set_text(GTK_ENTRY(entry), ipv4_config.gateway); ++ gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 4, 3, 4); ++ data->ipv4.entry[2] = entry; ++ ++ data->ipv4_config = ipv4_config; ++ ++ button = gtk_button_new_with_label(_("Apply")); ++ gtk_table_attach_defaults(GTK_TABLE(table), button, 3, 4, 4, 5); ++ g_signal_connect(G_OBJECT(button), "clicked", ++ G_CALLBACK(apply_callback), data); ++ ++ data->button = button; ++ ++ if (g_str_equal(ipv4_config.method, "dhcp") == TRUE) ++ update_ethernet_ipv4(data, CONNMAN_POLICY_DHCP); ++ else ++ update_ethernet_ipv4(data, CONNMAN_POLICY_MANUAL); + + g_signal_connect(G_OBJECT(combo), "changed", +- G_CALLBACK(changed_callback), data); ++ G_CALLBACK(changed_callback), data); + } + +-void update_ethernet_policy(struct config_data *data, guint policy) ++void update_ethernet_ipv4(struct config_data *data, guint policy) + { + GtkWidget *combo = data->policy.config; +- gchar *info = NULL; ++ GtkWidget *entry[3]; ++ int i; ++ ++ for (i = 0; i < 3; i++) ++ entry[i] = data->ipv4.entry[i]; + + g_signal_handlers_block_by_func(G_OBJECT(combo), +- G_CALLBACK(changed_callback), data); ++ G_CALLBACK(changed_callback), data); + + switch (policy) { +- case CONNMAN_POLICY_OFF: +- gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 3); ++ case CONNMAN_POLICY_DHCP: ++ gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); ++ for (i = 0; i < 3; i++) { ++ gtk_entry_set_editable(GTK_ENTRY(entry[i]), 0); ++ gtk_widget_set_sensitive(entry[i], 0); ++ gtk_entry_set_text(GTK_ENTRY(entry[i]), _("")); ++ } + break; +- case CONNMAN_POLICY_IGNORE: ++ case CONNMAN_POLICY_MANUAL: + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 1); +- info = g_strdup_printf(_("Ignore the interface and don't " +- "make any attempts for configuration.")); +- break; +- case CONNMAN_POLICY_AUTO: +- gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); +- info = g_strdup_printf(_("Detect carrier and then " +- "automatically configure the interface.")); ++ for (i = 0; i < 3; i++) { ++ gtk_entry_set_editable(GTK_ENTRY(entry[i]), 1); ++ gtk_widget_set_sensitive(entry[i], 1); ++ } + break; + default: + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), -1); +@@ -124,9 +199,5 @@ void update_ethernet_policy(struct config_data *data, guint policy) + } + + g_signal_handlers_unblock_by_func(G_OBJECT(combo), +- G_CALLBACK(changed_callback), data); +- +- gtk_label_set_markup(GTK_LABEL(data->policy.label), info); +- +- g_free(info); ++ G_CALLBACK(changed_callback), data); + } +diff --git a/properties/main.c b/properties/main.c +index 01439e6..3701f16 100644 +--- a/properties/main.c ++++ b/properties/main.c +@@ -33,102 +33,54 @@ + static ConnmanClient *client; + static GtkWidget *interface_notebook; + +-static void update_status(struct config_data *data, +- guint type, gboolean inrange, guint policy, +- const gchar *network, const gchar *address) ++static void get_state_realtime(GtkTreeModel *model, GtkTreePath *path, ++ GtkTreeIter *iter, gpointer user_data) + { +- const char *str; +- gchar *markup, *info = NULL; +- +- switch (type) { +- case CONNMAN_TYPE_ETHERNET: +- if (inrange == TRUE) { +- str = N_("Connected"); +- info = g_strdup_printf(_("%s is currently active " +- "and has the IP address %s."), +- N_("Ethernet"), address); ++ struct config_data *data = user_data; ++ guint type, strength; ++ const gchar *name = NULL, *_name = NULL, *state = NULL; ++ ++ if (data->wifi.name) ++ _name = gtk_label_get_text(GTK_LABEL(data->wifi.name)); ++ ++ gtk_tree_model_get(model, iter, CONNMAN_COLUMN_STRENGTH, &strength, ++ CONNMAN_COLUMN_STATE, &state, ++ CONNMAN_COLUMN_NAME, &name, ++ CONNMAN_COLUMN_TYPE, &type, ++ -1); ++ ++ if (name && _name && g_str_equal(name, _name) == TRUE && data->connecting) { ++ if (g_str_equal(state, "failure") == TRUE) { ++ gtk_label_set_text(GTK_LABEL(data->wifi.connect_info), ++ _("connection failed")); ++ gtk_widget_show(data->wifi.connect_info); ++ gtk_widget_show(data->wifi.connect); ++ gtk_widget_hide(data->wifi.disconnect); ++ data->connecting = 0; ++ } else if (g_str_equal(state, "idle") == TRUE) { ++ gtk_widget_hide(data->wifi.connect_info); ++ gtk_widget_show(data->wifi.connect); ++ gtk_widget_hide(data->wifi.disconnect); ++ data->connecting = 0; + } else { +- str = N_("Cable Unplugged"); +- info = g_strdup_printf(_("The cable for %s is " +- "not plugged in."), N_("Ethernet")); ++ gtk_widget_hide(data->wifi.connect_info); ++ gtk_widget_hide(data->wifi.connect); ++ gtk_widget_show(data->wifi.disconnect); + } +- break; +- +- case CONNMAN_TYPE_WIFI: +- if (inrange == TRUE) { +- str = N_("Connected"); +- info = g_strdup_printf(_("%s is currently active " +- "and has the IP address %s."), +- N_("Wireless"), address); +- } else +- str = N_("Not Connected"); +- break; +- +- default: +- if (inrange == TRUE) +- str = N_("Connected"); +- else +- str = N_("Not Connected"); +- break; + } +- +- markup = g_strdup_printf("<b>%s</b>", str); +- gtk_label_set_markup(GTK_LABEL(data->title), markup); +- g_free(markup); +- +- gtk_label_set_markup(GTK_LABEL(data->label), info); +- +- g_free(info); +- +- switch (type) { +- case CONNMAN_TYPE_ETHERNET: +- update_ethernet_policy(data, policy); +- break; +- case CONNMAN_TYPE_WIFI: +- update_wifi_policy(data, policy); +- break; +- default: +- break; +- } +-} +- +-static void update_config(struct config_data *data) +-{ +- GtkTreeIter iter; +- guint type; +- gchar *network; +- +- if (gtk_tree_model_get_iter_from_string(data->model, +- &iter, data->index) == FALSE) +- return; +- +- gtk_tree_model_get(data->model, &iter, +- CONNMAN_COLUMN_TYPE, &type, +- CONNMAN_COLUMN_NAME, &network, -1); +- +- g_free(network); +-} +- +-static void advanced_callback(GtkWidget *button, gpointer user_data) +-{ +- struct config_data *data = user_data; +- +- gtk_widget_show_all(data->dialog); + } + + static struct config_data *create_config(GtkTreeModel *model, +- GtkTreeIter *iter, gpointer user_data) ++ GtkTreeIter *iter, gpointer user_data) + { + GtkWidget *mainbox; + GtkWidget *label; + GtkWidget *hbox; +- GtkWidget *button; + struct config_data *data; + DBusGProxy *proxy; +- guint type, policy; +- gboolean inrange; +- gchar *markup, *vendor = NULL, *product = NULL; +- gchar *network = NULL, *address = NULL; ++ guint type; ++ gchar *vendor = NULL, *product = NULL; ++ gchar *address = NULL, *state = NULL; + + data = g_try_new0(struct config_data, 1); + if (data == NULL) +@@ -137,14 +89,16 @@ static struct config_data *create_config(GtkTreeModel *model, + data->client = client; + + gtk_tree_model_get(model, iter, +- CONNMAN_COLUMN_PROXY, &proxy, +- CONNMAN_COLUMN_TYPE, &type, +- CONNMAN_COLUMN_INRANGE, &inrange, +- CONNMAN_COLUMN_NETWORK, &network, +- CONNMAN_COLUMN_ADDRESS, &address, +- CONNMAN_COLUMN_POLICY, &policy, -1); ++ CONNMAN_COLUMN_PROXY, &proxy, ++ CONNMAN_COLUMN_TYPE, &type, ++ CONNMAN_COLUMN_ADDRESS, &address, ++ CONNMAN_COLUMN_STATE, &state, ++ -1); + + data->device = g_strdup(dbus_g_proxy_get_path(proxy)); ++ data->model = model; ++ data->index = gtk_tree_model_get_string_from_iter(model, iter); ++ + g_object_unref(proxy); + + mainbox = gtk_vbox_new(FALSE, 6); +@@ -163,12 +117,14 @@ static struct config_data *create_config(GtkTreeModel *model, + gtk_box_pack_start(GTK_BOX(mainbox), label, FALSE, FALSE, 0); + data->label = label; + ++ data->window = user_data; ++ + switch (type) { + case CONNMAN_TYPE_ETHERNET: +- add_ethernet_policy(mainbox, data); ++ add_ethernet_policy(mainbox, iter, data); + break; + case CONNMAN_TYPE_WIFI: +- add_wifi_policy(mainbox, data); ++ add_wifi_policy(mainbox, iter, data); + break; + default: + break; +@@ -183,32 +139,12 @@ static struct config_data *create_config(GtkTreeModel *model, + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 1.0); + gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); + +- markup = g_strdup_printf("%s\n<small>%s</small>", +- vendor ? vendor : "", product ? product : ""); +- gtk_label_set_markup(GTK_LABEL(label), markup); +- g_free(markup); +- +- if (0) { +- button = gtk_button_new_with_label(_("Advanced...")); +- gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); +- g_signal_connect(G_OBJECT(button), "clicked", +- G_CALLBACK(advanced_callback), data); +- data->button = button; +- } +- +- data->window = user_data; +- create_advanced_dialog(data, type); +- +- update_status(data, type, inrange, policy, network, address); +- +- g_free(network); + g_free(address); + +- data->model = model; +- data->index = gtk_tree_model_get_string_from_iter(model, iter); +- + gtk_widget_show_all(mainbox); + ++ g_signal_connect(G_OBJECT(model), "row-changed", ++ G_CALLBACK(get_state_realtime), data); + g_free(product); + g_free(vendor); + +@@ -230,67 +166,56 @@ static void select_callback(GtkTreeSelection *selection, gpointer user_data) + return; + } + +- if (data == NULL) { +- data = create_config(model, &iter, user_data); +- if (data == NULL) +- return; +- +- page = gtk_notebook_append_page(GTK_NOTEBOOK(notebook), +- data->widget, NULL); +- } else { +- update_config(data); +- +- page = gtk_notebook_page_num(GTK_NOTEBOOK(notebook), +- data->widget); +- } ++ data = create_config(model, &iter, user_data); ++ if (data == NULL) ++ return; + ++ page = gtk_notebook_append_page(GTK_NOTEBOOK(notebook), ++ data->widget, NULL); + gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), page); + + gtk_widget_show(notebook); + } + +-static void row_changed(GtkTreeModel *model, GtkTreePath *path, +- GtkTreeIter *iter, gpointer user_data) +-{ +- guint type; +- gboolean powered, inrange; +- +- gtk_tree_model_get(model, iter, CONNMAN_COLUMN_TYPE, &type, +- CONNMAN_COLUMN_ENABLED, &powered, +- CONNMAN_COLUMN_INRANGE, &inrange, -1); +-} +- +-static void state_to_icon(GtkTreeViewColumn *column, GtkCellRenderer *cell, +- GtkTreeModel *model, GtkTreeIter *iter, gpointer data) ++static void strength_to_icon(GtkTreeViewColumn *column, GtkCellRenderer *cell, ++ GtkTreeModel *model, GtkTreeIter *iter, gpointer data) + { +- gboolean inrange; +- +- gtk_tree_model_get(model, iter, CONNMAN_COLUMN_INRANGE, &inrange, -1); +- +- if (inrange == TRUE) +- g_object_set(cell, "icon-name", GTK_STOCK_YES, NULL); +- else +- g_object_set(cell, "icon-name", NULL, NULL); ++ GdkPixbuf *pix; ++ guint strength, type; ++ gchar *name; ++ ++ gtk_tree_model_get(model, iter, CONNMAN_COLUMN_STRENGTH, &strength, ++ CONNMAN_COLUMN_TYPE, &type, ++ -1); ++ ++ if (type == CONNMAN_TYPE_WIFI) { ++ name = (gchar *)g_strdup_printf("%s/connman-signal-0%d.png", ++ ICONDIR, (strength-1)/20+1); ++ pix = gdk_pixbuf_new_from_file(name, NULL); ++ g_object_set(cell, "pixbuf", pix, NULL); ++ } else ++ g_object_set(cell, "pixbuf", NULL, NULL); + } + +-static void type_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell, +- GtkTreeModel *model, GtkTreeIter *iter, gpointer data) ++static void device_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell, ++ GtkTreeModel *model, GtkTreeIter *iter, gpointer data) + { + guint type; +- gboolean powered, inrange; +- gchar *markup; +- const char *title, *info; ++ gchar *markup, *name, *state; ++ const char *title; + + gtk_tree_model_get(model, iter, CONNMAN_COLUMN_TYPE, &type, +- CONNMAN_COLUMN_ENABLED, &powered, +- CONNMAN_COLUMN_INRANGE, &inrange, -1); ++ CONNMAN_COLUMN_NAME, &name, ++ CONNMAN_COLUMN_STATE, &state, ++ -1); + + switch (type) { + case CONNMAN_TYPE_ETHERNET: + title = N_("Ethernet"); + break; + case CONNMAN_TYPE_WIFI: +- title = N_("Wireless"); ++ /* Show the AP name */ ++ title = N_(name); + break; + case CONNMAN_TYPE_WIMAX: + title = N_("WiMAX"); +@@ -303,21 +228,27 @@ static void type_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell, + break; + } + +- if (powered == TRUE) { +- if (inrange == TRUE) +- info = N_("Connected"); ++ /* Set wifi connection status. */ ++ if (type == CONNMAN_TYPE_WIFI) { ++ if (g_str_equal(state, "association") == TRUE) ++ state = "associating..."; ++ else if (g_str_equal(state, "configuration") == TRUE) ++ state = "configurating..."; ++ else if (g_str_equal(state, "ready") == TRUE || ++ g_str_equal(state, "online") == TRUE) ++ state = "connnected"; + else +- info = N_("Not Connected"); ++ state = ""; ++ markup = g_strdup_printf("<b>%s</b>\n%s\n", title, state); + } else +- info = N_("Disabled"); ++ markup = g_strdup_printf("<b>%s</b>\n", title); + +- markup = g_strdup_printf("<b>%s</b>\n<small>%s</small>", title, info); + g_object_set(cell, "markup", markup, NULL); + g_free(markup); + } + + static void type_to_icon(GtkTreeViewColumn *column, GtkCellRenderer *cell, +- GtkTreeModel *model, GtkTreeIter *iter, gpointer data) ++ GtkTreeModel *model, GtkTreeIter *iter, gpointer data) + { + guint type; + +@@ -326,16 +257,16 @@ static void type_to_icon(GtkTreeViewColumn *column, GtkCellRenderer *cell, + switch (type) { + case CONNMAN_TYPE_ETHERNET: + g_object_set(cell, "icon-name", "network-wired", +- "stock-size", 5, NULL); ++ "stock-size", 5, NULL); + break; + case CONNMAN_TYPE_WIFI: + case CONNMAN_TYPE_WIMAX: + g_object_set(cell, "icon-name", "network-wireless", +- "stock-size", 5, NULL); ++ "stock-size", 5, NULL); + break; + case CONNMAN_TYPE_BLUETOOTH: + g_object_set(cell, "icon-name", "bluetooth", +- "stock-size", 5, NULL); ++ "stock-size", 5, NULL); + break; + default: + g_object_set(cell, "icon-name", NULL, NULL); +@@ -362,9 +293,9 @@ static GtkWidget *create_interfaces(GtkWidget *window) + + scrolled = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), +- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); ++ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), +- GTK_SHADOW_OUT); ++ GTK_SHADOW_OUT); + gtk_box_pack_start(GTK_BOX(hbox), scrolled, FALSE, TRUE, 0); + + tree = gtk_tree_view_new(); +@@ -381,21 +312,19 @@ static GtkWidget *create_interfaces(GtkWidget *window) + gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); + + renderer = gtk_cell_renderer_pixbuf_new(); +- gtk_cell_renderer_set_fixed_size(renderer, 20, 45); + gtk_tree_view_column_pack_start(column, renderer, FALSE); + gtk_tree_view_column_set_cell_data_func(column, renderer, +- state_to_icon, NULL, NULL); +- +- renderer = gtk_cell_renderer_text_new(); +- gtk_tree_view_column_pack_start(column, renderer, TRUE); +- gtk_tree_view_column_set_cell_data_func(column, renderer, +- type_to_text, NULL, NULL); ++ strength_to_icon, NULL, NULL); + + renderer = gtk_cell_renderer_pixbuf_new(); +- gtk_tree_view_column_pack_end(column, renderer, FALSE); ++ gtk_tree_view_column_pack_start(column, renderer, FALSE); + gtk_tree_view_column_set_cell_data_func(column, renderer, +- type_to_icon, NULL, NULL); ++ type_to_icon, NULL, NULL); + ++ renderer = gtk_cell_renderer_text_new(); ++ gtk_tree_view_column_pack_start(column, renderer, FALSE); ++ gtk_tree_view_column_set_cell_data_func(column, renderer, ++ device_to_text, NULL, NULL); + + interface_notebook = gtk_notebook_new(); + gtk_notebook_set_show_tabs(GTK_NOTEBOOK(interface_notebook), FALSE); +@@ -410,16 +339,13 @@ static GtkWidget *create_interfaces(GtkWidget *window) + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); + gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); + g_signal_connect(G_OBJECT(selection), "changed", +- G_CALLBACK(select_callback), window); +- +- g_signal_connect(G_OBJECT(model), "row-changed", +- G_CALLBACK(row_changed), selection); ++ G_CALLBACK(select_callback), window); + + return mainbox; + } + + static gboolean delete_callback(GtkWidget *window, GdkEvent *event, +- gpointer user_data) ++ gpointer user_data) + { + gtk_widget_destroy(window); + +@@ -451,7 +377,7 @@ static GtkWidget *create_window(void) + gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); + gtk_window_set_default_size(GTK_WINDOW(window), 580, 380); + g_signal_connect(G_OBJECT(window), "delete-event", +- G_CALLBACK(delete_callback), NULL); ++ G_CALLBACK(delete_callback), NULL); + + vbox = gtk_vbox_new(FALSE, 12); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); +@@ -467,12 +393,12 @@ static GtkWidget *create_window(void) + button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); + gtk_container_add(GTK_CONTAINER(buttonbox), button); + g_signal_connect(G_OBJECT(button), "clicked", +- G_CALLBACK(close_callback), window); ++ G_CALLBACK(close_callback), window); + + widget = create_interfaces(window); + gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook), widget, NULL); + gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(notebook), +- widget, _("Devices")); ++ widget, _("Services")); + + gtk_widget_show_all(window); + +diff --git a/properties/wifi.c b/properties/wifi.c +index 320dce4..3d3cee8 100644 +--- a/properties/wifi.c ++++ b/properties/wifi.c +@@ -23,6 +23,7 @@ + #include <config.h> + #endif + ++#include <dbus/dbus-glib.h> + #include <glib/gi18n.h> + #include <gtk/gtk.h> + +@@ -30,6 +31,24 @@ + + #include "advanced.h" + ++static void update_wifi_ipv4(struct config_data *data, guint policy); ++ ++static gboolean separator_function(GtkTreeModel *model, ++ GtkTreeIter *iter, gpointer user_data) ++{ ++ gchar *text; ++ gboolean result = FALSE; ++ ++ gtk_tree_model_get(model, iter, 0, &text, -1); ++ ++ if (text && *text == '\0') ++ result = TRUE; ++ ++ g_free(text); ++ ++ return result; ++} ++ + static void changed_callback(GtkWidget *editable, gpointer user_data) + { + struct config_data *data = user_data; +@@ -37,98 +56,310 @@ static void changed_callback(GtkWidget *editable, gpointer user_data) + + active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->policy.config)); + +- switch (active) { +- case 0: +- connman_client_set_policy(data->client, data->device, "auto"); +- update_wifi_policy(data, CONNMAN_POLICY_AUTO); +- break; +- case 1: +- connman_client_set_policy(data->client, data->device, "manual"); +- update_wifi_policy(data, CONNMAN_POLICY_MANUAL); +- break; +- case 3: +- connman_client_set_policy(data->client, data->device, "off"); +- update_wifi_policy(data, CONNMAN_POLICY_OFF); +- break; ++ update_wifi_ipv4(data, active); ++} ++ ++static void connect_reply_cb(DBusGProxy *proxy, GError *error, ++ gpointer user_data) ++{ ++ struct config_data *data = user_data; ++ if (error) ++ { ++ gtk_label_set_text(GTK_LABEL(data->wifi.connect_info), ++ _("connection failed")); ++ gtk_widget_show(data->wifi.connect_info); ++ gtk_widget_show(data->wifi.connect); ++ gtk_widget_hide(data->wifi.disconnect); ++ data->connecting = 0; ++ g_error_free(error); ++ } ++} ++ ++static void connect_callback(GtkWidget *editable, gpointer user_data) ++{ ++ struct config_data *data = user_data; ++ ++ const gchar *passphrase; ++ ++ gboolean ret; ++ gint active; ++ ++ gtk_widget_hide(data->wifi.connect); ++ gtk_widget_show(data->wifi.disconnect); ++ ++ data->connecting = 1; ++ ++ if (data->wifi.passphrase) { ++ passphrase = gtk_entry_get_text(GTK_ENTRY(data->wifi.passphrase)); ++ ret = connman_client_set_passphrase(data->client, data->device, ++ passphrase); ++ } ++ ++ connman_client_connect_async(data->client, data->device, connect_reply_cb, data); ++ ++ active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->policy.config)); ++ data->ipv4_config.method = active ? "manual" : "dhcp"; ++ data->ipv4_config.address = active ? gtk_entry_get_text(GTK_ENTRY(data->ipv4.entry[0])) : NULL; ++ data->ipv4_config.netmask = active ? gtk_entry_get_text(GTK_ENTRY(data->ipv4.entry[1])) : NULL; ++ data->ipv4_config.gateway = active ? gtk_entry_get_text(GTK_ENTRY(data->ipv4.entry[2])) : NULL; ++ ++ connman_client_set_ipv4(data->client, data->device, &data->ipv4_config); ++ ++} ++ ++static void disconnect_callback(GtkWidget *editable, gpointer user_data) ++{ ++ struct config_data *data = user_data; ++ gboolean ret; ++ ++ data->connecting = 0; ++ ++ ret = connman_client_disconnect(data->client, data->device); ++ if (ret == TRUE) { ++ gtk_widget_show(data->wifi.connect); ++ gtk_widget_hide(data->wifi.disconnect); + } + } + +-void add_wifi_policy(GtkWidget *mainbox, struct config_data *data) ++static void wifi_ipconfig(GtkWidget *table, struct config_data *data, GtkTreeIter *iter) + { + GtkWidget *vbox; +- GtkWidget *table; ++ GtkWidget *dialog; ++ GtkWidget *entry; + GtkWidget *label; + GtkWidget *combo; ++ GtkWidget *buttonbox; ++ GtkWidget *button; ++ DBusGProxy *proxy; + +- vbox = gtk_vbox_new(FALSE, 0); +- gtk_container_set_border_width(GTK_CONTAINER(vbox), 24); +- gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0); ++ struct ipv4_config ipv4_config = { ++ .method = NULL, ++ .address = NULL, ++ .netmask = NULL, ++ .gateway = NULL, ++ }; + +- table = gtk_table_new(2, 4, FALSE); +- gtk_table_set_row_spacings(GTK_TABLE(table), 8); +- gtk_table_set_col_spacings(GTK_TABLE(table), 8); +- gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); ++ gtk_tree_model_get(data->model, iter, ++ CONNMAN_COLUMN_PROXY, &proxy, ++ CONNMAN_COLUMN_METHOD, &ipv4_config.method, ++ CONNMAN_COLUMN_ADDRESS, &ipv4_config.address, ++ CONNMAN_COLUMN_NETMASK, &ipv4_config.netmask, ++ CONNMAN_COLUMN_GATEWAY, &ipv4_config.gateway, ++ -1); + +-#if 0 +- label = gtk_label_new(_("Network Name:")); +- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); +- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); +- gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); ++ label = gtk_label_new(_("Configuration:")); ++ gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 3, 4); ++// gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); ++// gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); ++ data->ipv4.label[0] = label; + + combo = gtk_combo_box_new_text(); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Guest"); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), ""); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Off"); ++ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "DHCP"); ++ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Manual"); + gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(combo), +- separator_function, NULL, NULL); +- gtk_table_attach_defaults(GTK_TABLE(table), combo, 1, 4, 0, 1); ++ separator_function, NULL, NULL); ++ ++ gtk_table_attach_defaults(GTK_TABLE(table), combo, 2, 4, 3, 4); + data->policy.config = combo; +-#endif + +- label = gtk_label_new(_("Configuration:")); +- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); +- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); +- gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); ++ label = gtk_label_new(_("IP address:")); ++ gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 4, 5); ++// gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); ++// gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); ++ data->ipv4.label[0] = label; + +- combo = gtk_combo_box_new_text(); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Automatically"); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Manually"); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), ""); +- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Off"); +- gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(combo), +- separator_function, NULL, NULL); +- gtk_table_attach_defaults(GTK_TABLE(table), combo, 1, 4, 0, 1); +- data->policy.config = combo; ++ entry = gtk_entry_new(); ++ gtk_entry_set_max_length (GTK_ENTRY (entry), 15); ++ if (ipv4_config.address) ++ gtk_entry_set_text(GTK_ENTRY(entry), ipv4_config.address); ++ gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 4, 4, 5); ++ data->ipv4.entry[0] = entry; ++ ++ label = gtk_label_new(_("Netmask:")); ++ gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 5, 6); ++// gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); ++// gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); ++ data->ipv4.label[1] = label; + +- label = gtk_label_new(NULL); +- gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); ++ entry = gtk_entry_new(); ++ gtk_entry_set_max_length (GTK_ENTRY (entry), 15); ++ if (ipv4_config.netmask) ++ gtk_entry_set_text(GTK_ENTRY(entry), ipv4_config.netmask); ++ gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 4, 5, 6); ++ data->ipv4.entry[1] = entry; ++ ++ label = gtk_label_new(_("Gateway:")); ++ gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 6, 7); ++// gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); ++// gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); ++ data->ipv4.label[2] = label; ++ ++ entry = gtk_entry_new(); ++ gtk_entry_set_max_length (GTK_ENTRY (entry), 15); ++ if (ipv4_config.gateway) ++ gtk_entry_set_text(GTK_ENTRY(entry), ipv4_config.gateway); ++ gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 4, 6, 7); ++ data->ipv4.entry[2] = entry; ++ ++ data->ipv4_config = ipv4_config; ++ ++ if (g_str_equal(ipv4_config.method, "dhcp") == TRUE) ++ update_wifi_ipv4(data, CONNMAN_POLICY_DHCP); ++ else ++ update_wifi_ipv4(data, CONNMAN_POLICY_MANUAL); ++ ++ g_signal_connect(G_OBJECT(combo), "changed", ++ G_CALLBACK(changed_callback), data); ++} ++ ++static void toggled_callback(GtkWidget *button, gpointer user_data) ++{ ++ GtkWidget *entry = user_data; ++ gboolean mode; ++ ++ mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); ++ ++ gtk_entry_set_visibility(GTK_ENTRY(entry), mode); ++} ++ ++void add_wifi_policy(GtkWidget *mainbox, GtkTreeIter *iter, struct config_data *data) ++{ ++ GtkWidget *vbox; ++ GtkWidget *table; ++ GtkWidget *label; ++ GtkWidget *entry; ++ GtkWidget *button; ++ ++ const gchar *name, *security, *icon, *state; ++ guint strength; ++ ++ gtk_tree_model_get(data->model, iter, ++ CONNMAN_COLUMN_NAME, &name, ++ CONNMAN_COLUMN_SECURITY, &security, ++ CONNMAN_COLUMN_ICON, &icon, ++ CONNMAN_COLUMN_STATE, &state, ++ CONNMAN_COLUMN_STRENGTH, &strength, ++ -1); ++ ++ vbox = gtk_vbox_new(TRUE, 0); ++ gtk_container_set_border_width(GTK_CONTAINER(vbox), 24); ++ gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0); ++ ++ table = gtk_table_new(10, 5, TRUE); ++ gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); ++ data->table = table; ++ ++ label = gtk_label_new(_("Access Point:")); ++ gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1); ++// gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); ++// gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); ++ ++ label = gtk_label_new(_(name)); ++ gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 4, 0, 1); ++ gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); ++ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); ++ data->wifi.name = label; ++ ++ label = gtk_label_new(_("Security:")); ++ gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); ++// gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); ++// gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); ++ ++ label = gtk_label_new(_(security)); ++ gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 4, 1, 2); + gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); ++ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); ++ data->wifi.security = label; ++ ++ label = gtk_label_new(_("Passphrase:")); ++ gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3); ++// gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); ++// gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); ++ ++ ++ if (g_str_equal(security, "none") != TRUE && ++ g_str_equal(security, "unknown") != TRUE) { ++ entry = gtk_entry_new(); ++ gtk_entry_set_max_length (GTK_ENTRY (entry), 64); ++ gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 4, 2, 3); ++ gtk_entry_set_visibility(GTK_ENTRY(entry), 0); ++ data->wifi.passphrase = entry; ++ ++ button = gtk_check_button_new_with_label(_("Show input")); ++ gtk_table_attach_defaults(GTK_TABLE(table), button, 4, 5, 2, 3); ++ ++ g_signal_connect(G_OBJECT(button), "toggled", ++ G_CALLBACK(toggled_callback), entry); ++ ++ ++ } else { ++ label = gtk_label_new(_("none")); ++ gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 4, 2, 3); ++ gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); ++ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); ++ data->wifi.passphrase = NULL; ++ } ++ ++ label = gtk_label_new(_("")); ++ gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 3, 8, 9); + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); +- gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 4, 1, 2); +- gtk_widget_set_size_request(label, 180, -1); +- data->policy.label = label; ++ gtk_widget_hide(label); ++ data->wifi.connect_info = label; ++ ++ button = gtk_button_new_with_label(_("Connect")); ++ gtk_table_attach_defaults(GTK_TABLE(table), button, 3, 4, 8, 9); ++ g_signal_connect(G_OBJECT(button), "clicked", ++ G_CALLBACK(connect_callback), data); ++ gtk_widget_set_no_show_all(button, TRUE); ++ data->wifi.connect = button; ++ ++ button = gtk_button_new_with_label(_("Disconnect")); ++ gtk_table_attach_defaults(GTK_TABLE(table), button, 3, 4, 8, 9); ++ g_signal_connect(G_OBJECT(button), "clicked", ++ G_CALLBACK(disconnect_callback), data); ++ data->wifi.disconnect = button; ++ gtk_widget_set_no_show_all(button, TRUE); ++ ++ if (g_str_equal(state, "failure") == TRUE ++ || g_str_equal(state, "idle") == TRUE) { ++ gtk_widget_show(data->wifi.connect); ++ gtk_widget_hide(data->wifi.disconnect); ++ } else { ++ gtk_widget_hide(data->wifi.connect); ++ gtk_widget_show(data->wifi.disconnect); ++ } ++ ++ wifi_ipconfig(table, data, iter); + +- g_signal_connect(G_OBJECT(combo), "changed", +- G_CALLBACK(changed_callback), data); + } + +-void update_wifi_policy(struct config_data *data, guint policy) ++void update_wifi_ipv4(struct config_data *data, guint policy) + { + GtkWidget *combo = data->policy.config; ++ GtkWidget *entry[3]; + gchar *info = NULL; ++ int i; ++ ++ for (i = 0; i < 3; i++) ++ entry[i] = data->ipv4.entry[i]; + + g_signal_handlers_block_by_func(G_OBJECT(combo), +- G_CALLBACK(changed_callback), data); ++ G_CALLBACK(changed_callback), data); + + switch (policy) { +- case CONNMAN_POLICY_OFF: +- gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 3); ++ case CONNMAN_POLICY_DHCP: ++ gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); ++ for (i = 0; i < 3; i++) { ++ gtk_entry_set_editable(GTK_ENTRY(entry[i]), 0); ++ gtk_widget_set_sensitive(entry[i], 0); ++ } + break; + case CONNMAN_POLICY_MANUAL: + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 1); +- break; +- case CONNMAN_POLICY_AUTO: +- gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); ++ for (i = 0; i < 3; i++) { ++ gtk_entry_set_editable(GTK_ENTRY(entry[i]), 1); ++ gtk_widget_set_sensitive(entry[i], 1); ++ } + break; + default: + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), -1); +@@ -136,9 +367,7 @@ void update_wifi_policy(struct config_data *data, guint policy) + } + + g_signal_handlers_unblock_by_func(G_OBJECT(combo), +- G_CALLBACK(changed_callback), data); +- +- gtk_label_set_markup(GTK_LABEL(data->policy.label), info); ++ G_CALLBACK(changed_callback), data); + + g_free(info); + } diff --git a/meta/recipes-connectivity/connman/connman-gnome_0.5.bb b/meta/recipes-connectivity/connman/connman-gnome_0.5.bb new file mode 100644 index 000000000..6958ee57b --- /dev/null +++ b/meta/recipes-connectivity/connman/connman-gnome_0.5.bb @@ -0,0 +1,22 @@ +DESCRIPTION = "gtk frontend for connman" +HOMEPAGE = "http://connman.net/" +SECTION = "libs/network" +LICENSE = "GPLv2 & LGPLv2.1" +LIC_FILES_CHKSUM = "file://COPYING;md5=eb723b61539feef013de476e68b5c50a \ + file://properties/main.c;beginline=1;endline=20;md5=50c77c81871308b033ab7a1504626afb \ + file://common/connman-dbus.c;beginline=1;endline=20;md5=de6b485c0e717a0236402d220187717a" +DEPENDS = "gtk+ dbus" +PR = "r0" + +RRECOMMENDS_${PN} = "python python-dbus connman connman-plugin-ethernet connman-plugin-loopback connman-plugin-udhcp connman-plugin-wifi connman-plugin-fake connman-plugin-bluetooth connman-plugin-dnsproxy" + +SRC_URI = "http://www.kernel.org/pub/linux/network/connman/connman-gnome-${PV}.tar.gz \ + file://connman-gnome.patch \ + file://connman-applet.desktop" + +inherit autotools gtk-icon-cache + +do_install_append() { + install -d ${D}${datadir}/applications/ + install ${WORKDIR}/connman-applet.desktop ${D}${datadir}/applications/ +} diff --git a/meta/recipes-connectivity/connman/connman-gnome_git.bb b/meta/recipes-connectivity/connman/connman-gnome_git.bb deleted file mode 100644 index 440ba285c..000000000 --- a/meta/recipes-connectivity/connman/connman-gnome_git.bb +++ /dev/null @@ -1,9 +0,0 @@ - -SRC_URI = "git://git.kernel.org/pub/scm/network/connman/connman-gnome.git;protocol=git" -DEPENDS = "gtk+" -PV = "0.1+git${SRCPV}" -PR = "r0" - -S = "${WORKDIR}/git" - -inherit autotools diff --git a/meta/recipes-connectivity/connman/connman.inc b/meta/recipes-connectivity/connman/connman.inc index 9a623d7f4..c842d3cbf 100644 --- a/meta/recipes-connectivity/connman/connman.inc +++ b/meta/recipes-connectivity/connman/connman.inc @@ -1,17 +1,13 @@ -HOMEPAGE = "http://www.moblin.org/projects/projects_connman.php" -SUMMARY = "Moblin Connection Manager" -LICENSE = "GPL" +DESCRIPTION = "The ConnMan project provides a daemon for managing \ +internet connections within embedded devices running the Linux operating system" +HOMEPAGE = "http://connman.net/" +BUGTRACKER = "http://bugs.meego.com/buglist.cgi?quicksearch=connman" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e \ + file://src/main.c;beginline=1;endline=20;md5=4b55b550fa6b33cc2055ef30dd262b3e" DEPENDS = "libgdbus dbus glib-2.0 hal" -RDEPENDS_${PN} = "dhcp-client wpa-supplicant resolvconf" - -EXTRA_OECONF += " \ - --enable-ethernet=builtin --enable-wifi=builtin --enable-dhclient=builtin \ - --enable-bluetooth=builtin --enable-udev --enable-loopback=builtin \ - --enable-dnsproxy=builtin --enable-threads --enable-resolvconf=builtin \ - --enable-client --enable-fake --with-dhclient=/sbin/dhclient \ - --enable-test \ - ac_cv_path_WPASUPPLICANT=/usr/sbin/wpa_supplicant" +RDEPENDS_${PN} = "wpa-supplicant resolvconf" INITSCRIPT_NAME = "connman" INITSCRIPT_PARAMS = "start 05 5 2 . stop 22 0 1 6 ." @@ -39,5 +35,5 @@ FILES_${PN}-dbg += "${libdir}/connman/plugins/.debug \ python populate_packages_prepend() { plugin_dir = bb.data.expand('${libdir}/connman/plugins/', d) plugin_name = bb.data.expand('${PN}-plugin-%s', d) - do_split_packages(d, plugin_dir, '^lib(.*).so$', plugin_name, '${PN} plugin for %s', extra_depends='' ) -}
\ No newline at end of file + do_split_packages(d, plugin_dir, '^(.*).so$', plugin_name, '${PN} plugin for %s', extra_depends='' ) +} diff --git a/meta/recipes-connectivity/connman/connman_0.48.bb b/meta/recipes-connectivity/connman/connman_0.48.bb deleted file mode 100644 index 269f98721..000000000 --- a/meta/recipes-connectivity/connman/connman_0.48.bb +++ /dev/null @@ -1,7 +0,0 @@ -require connman.inc -PR = "r0" - -SRC_URI = "http://www.kernel.org/pub/linux/network/connman/${P}.tar.bz2 \ - file://dbusperms.patch \ - file://connman " - diff --git a/meta/recipes-connectivity/connman/connman_0.56.bb b/meta/recipes-connectivity/connman/connman_0.56.bb new file mode 100644 index 000000000..24ae536a7 --- /dev/null +++ b/meta/recipes-connectivity/connman/connman_0.56.bb @@ -0,0 +1,25 @@ +require connman.inc +PR = "r0" + +EXTRA_OECONF += "\ + ac_cv_path_WPASUPPLICANT=/usr/sbin/wpa_supplicant \ + --disable-gtk-doc \ + --enable-debug \ + --enable-threads \ + --enable-loopback \ + --enable-ethernet \ + --enable-wifi \ + --enable-bluetooth \ + --enable-dnsproxy \ + --disable-dhclient \ + --enable-test \ + --disable-udev \ + --disable-polkit \ + --enable-client \ + --enable-fake \ + --prefix=/usr --sysconfdir=/etc --localstatedir=/var" + +SRC_URI = "\ + http://www.kernel.org/pub/linux/network/connman/connman-${PV}.tar.gz \ + file://connman \ +" diff --git a/meta/recipes-connectivity/connman/files/connman-install-tests-d52de88aff4771283b2ebee4f48a7af15862d0ae.patch b/meta/recipes-connectivity/connman/files/connman-install-tests-d52de88aff4771283b2ebee4f48a7af15862d0ae.patch deleted file mode 100644 index 57df7196e..000000000 --- a/meta/recipes-connectivity/connman/files/connman-install-tests-d52de88aff4771283b2ebee4f48a7af15862d0ae.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: git/test/Makefile.am -=================================================================== ---- git.orig/test/Makefile.am 2009-05-21 12:07:39.000000000 +0100 -+++ git/test/Makefile.am 2009-05-21 17:29:33.000000000 +0100 -@@ -1,5 +1,7 @@ - --EXTRA_DIST = get-state list-profiles list-services \ -+testdir = $(pkgdatadir)/tests -+ -+test_SCRIPTS = get-state list-profiles list-services \ - list-connections select-connection \ - list-devices enable-device disable-device start-scanning \ - list-networks select-network disable-network create-network \ diff --git a/meta/recipes-connectivity/connman/files/connman-install-tests.patch b/meta/recipes-connectivity/connman/files/connman-install-tests.patch deleted file mode 100644 index 0ea3758f2..000000000 --- a/meta/recipes-connectivity/connman/files/connman-install-tests.patch +++ /dev/null @@ -1,15 +0,0 @@ -Index: git/Makefile.am -=================================================================== ---- git.orig/Makefile.am 2009-08-24 15:56:33.000000000 +0100 -+++ git/Makefile.am 2009-08-24 16:02:38.000000000 +0100 -@@ -115,7 +115,9 @@ - tools_wifi_scan_LDADD = @GLIB_LIBS@ @NETLINK_LIBS@ - endif - --EXTRA_DIST += test/get-state test/list-profiles test/list-services \ -+testdir = $(pkgdatadir)/tests -+ -+test_SCRIPTS = test/get-state test/list-profiles test/list-services \ - test/connect-service test/list-connections \ - test/select-connection test/list-devices test/enable-device \ - test/disable-device test/start-scanning test/list-networks \ diff --git a/meta/recipes-connectivity/connman/files/udevfix.patch b/meta/recipes-connectivity/connman/files/udevfix.patch deleted file mode 100644 index 803bec528..000000000 --- a/meta/recipes-connectivity/connman/files/udevfix.patch +++ /dev/null @@ -1,12 +0,0 @@ -Index: git/src/connman.rules -=================================================================== ---- git.orig/src/connman.rules 2009-05-25 14:24:53.000000000 +0100 -+++ git/src/connman.rules 2009-05-25 14:25:16.000000000 +0100 -@@ -3,6 +3,7 @@ - - SUBSYSTEM=="net", KERNEL=="eth*", ENV{CONNMAN_TYPE}="ethernet" - SUBSYSTEM=="net", KERNEL=="wlan*", ENV{CONNMAN_TYPE}="wifi" -+SUBSYSTEM=="net", KERNEL=="ra0", ENV{CONNMAN_TYPE}="wifi" - - SUBSYSTEM=="net", DRIVERS=="hso", ENV{CONNMAN_TYPE}="hso" - diff --git a/meta/recipes-sato/tasks/task-poky-x11-sato.bb b/meta/recipes-sato/tasks/task-poky-x11-sato.bb index 1b344edb5..662e15651 100644 --- a/meta/recipes-sato/tasks/task-poky-x11-sato.bb +++ b/meta/recipes-sato/tasks/task-poky-x11-sato.bb @@ -4,7 +4,7 @@ DESCRIPTION = "Sato Tasks for Poky" LICENSE = "MIT" -PR = "r29" +PR = "r30" PACKAGES = "\ task-poky-x11-sato \ @@ -16,7 +16,7 @@ PACKAGE_ARCH = "${MACHINE_ARCH}" ALLOW_EMPTY = "1" -NETWORK_MANAGER ?= "networkmanager-applet" +NETWORK_MANAGER ?= "connman-gnome" RDEPENDS_task-poky-x11-sato = "\ matchbox-desktop \ matchbox-session-sato \ |