summaryrefslogtreecommitdiff
path: root/meta/recipes-connectivity
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-connectivity')
-rw-r--r--meta/recipes-connectivity/connman/connman-gnome/connman-gnome.patch1716
-rw-r--r--meta/recipes-connectivity/connman/connman-gnome_0.5.bb2
2 files changed, 1134 insertions, 584 deletions
diff --git a/meta/recipes-connectivity/connman/connman-gnome/connman-gnome.patch b/meta/recipes-connectivity/connman/connman-gnome/connman-gnome.patch
index 52b105e47..2fe8bb80f 100644
--- a/meta/recipes-connectivity/connman/connman-gnome/connman-gnome.patch
+++ b/meta/recipes-connectivity/connman/connman-gnome/connman-gnome.patch
@@ -12,13 +12,23 @@ 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
+index 2a9b36e..08d394c 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);
+@@ -98,279 +98,21 @@ static void settings_callback(GtkWidget *item, gpointer user_data)
+ g_printerr("Couldn't execute command: %s\n", command);
}
+-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);
+-}
+-
-static void passphrase_dialog(const char *path, const char *name)
-{
- GtkWidget *dialog;
@@ -149,25 +159,49 @@ index 2a9b36e..1243a41 100644
- return menu;
-}
-
- static GtkWidget *append_menuitem(GtkMenu *menu, const char *ssid,
+-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);
+-{
+- GtkWidget *item;
+- GtkWidget *hbox;
+- GtkWidget *label;
+- GtkWidget *image;
+- GtkWidget *progress;
+-
+- item = gtk_check_menu_item_new();
+- gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM(item), TRUE);
+-
+- hbox = gtk_hbox_new(FALSE, 6);
+- gtk_container_add(GTK_CONTAINER(item), hbox);
+- gtk_widget_show(hbox);
+-
+- label = gtk_label_new(NULL);
+- gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+- gtk_label_set_text(GTK_LABEL(label), ssid);
+- gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
+- gtk_widget_show(label);
+-
+- 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;
- }
-
+- gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
+- gtk_widget_show(image);
+- }
+-
+- progress = gtk_progress_bar_new();
+- gtk_widget_set_size_request(progress, 100, -1);
+- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress),
+- (double) strength / 100);
+- gtk_box_pack_end(GTK_BOX(hbox), progress, FALSE, TRUE, 0);
+- gtk_widget_show(progress);
+-
+- gtk_widget_show(item);
+- gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+-
+- return item;
+-}
+-
-static void enumerate_networks(GtkMenu *menu,
- GtkTreeModel *model, GtkTreeIter *parent)
-{
@@ -265,7 +299,7 @@ index 2a9b36e..1243a41 100644
gtk_widget_show(item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-@@ -387,16 +182,17 @@ static void update_status(GtkTreeModel *model)
+@@ -387,16 +129,17 @@ static void update_status(GtkTreeModel *model)
cont = gtk_tree_model_get_iter_first(model, &iter);
while (cont == TRUE) {
@@ -286,7 +320,7 @@ index 2a9b36e..1243a41 100644
break;
cont = gtk_tree_model_iter_next(model, &iter);
-@@ -453,7 +249,7 @@ int main(int argc, char *argv[])
+@@ -453,7 +196,7 @@ int main(int argc, char *argv[])
g_set_application_name(_("Connection Manager"));
@@ -393,10 +427,10 @@ index ff3a996..8d74a46 100644
connman-dbus-glue.h \
instance-glue.h
diff --git a/common/connman-client.c b/common/connman-client.c
-index aad0a22..96f9388 100644
+index aad0a22..4f9cf64 100644
--- a/common/connman-client.c
+++ b/common/connman-client.c
-@@ -98,10 +98,9 @@ static void connman_client_init(ConnmanClient *client)
+@@ -98,13 +98,13 @@ 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,
@@ -406,11 +440,33 @@ index aad0a22..96f9388 100644
- 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_TYPE_STRING, G_TYPE_STRING,
++ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
g_object_set_data(G_OBJECT(priv->store),
- "State", g_strdup("unavailable"));
-@@ -197,7 +196,7 @@ static gboolean device_filter(GtkTreeModel *model,
+- "State", g_strdup("unavailable"));
++ "State", g_strdup("unavailable"));
+
+ priv->dbus = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
+@@ -191,13 +191,23 @@ static gboolean device_filter(GtkTreeModel *model,
+ {
+ DBusGProxy *proxy;
+ gboolean active;
++ guint type;
+
+- gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy, -1);
++ gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy,
++ CONNMAN_COLUMN_TYPE, &type,
++ -1);
++
++ switch (type) {
++ case CONNMAN_TYPE_LABEL_ETHERNET:
++ case CONNMAN_TYPE_LABEL_WIFI:
++ case CONNMAN_TYPE_SYSCONFIG:
++ return TRUE;
++ }
+
if (proxy == NULL)
return FALSE;
@@ -419,7 +475,7 @@ index aad0a22..96f9388 100644
dbus_g_proxy_get_interface(proxy));
g_object_unref(proxy);
-@@ -231,10 +230,10 @@ static gboolean device_network_filter(GtkTreeModel *model,
+@@ -231,10 +241,10 @@ static gboolean device_network_filter(GtkTreeModel *model,
if (proxy == NULL)
return FALSE;
@@ -432,7 +488,7 @@ index aad0a22..96f9388 100644
dbus_g_proxy_get_interface(proxy));
g_object_unref(proxy);
-@@ -277,7 +276,7 @@ GtkTreeModel *connman_client_get_network_model(ConnmanClient *client,
+@@ -277,7 +287,7 @@ GtkTreeModel *connman_client_get_network_model(ConnmanClient *client,
gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
CONNMAN_COLUMN_PROXY, &proxy, -1);
@@ -441,7 +497,7 @@ index aad0a22..96f9388 100644
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,
+@@ -314,7 +324,7 @@ static gboolean connection_filter(GtkTreeModel *model,
if (proxy == NULL)
return FALSE;
@@ -450,13 +506,13 @@ index aad0a22..96f9388 100644
dbus_g_proxy_get_interface(proxy));
g_object_unref(proxy);
-@@ -337,12 +336,19 @@ GtkTreeModel *connman_client_get_connection_model(ConnmanClient *client)
+@@ -337,28 +347,37 @@ 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,
++gboolean connman_client_set_ipv4(ConnmanClient *client, const gchar *device,
+ struct ipv4_config *ipv4_config)
{
ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client);
@@ -472,9 +528,14 @@ index aad0a22..96f9388 100644
DBG("client %p", client);
-@@ -353,10 +359,10 @@ void connman_client_set_policy(ConnmanClient *client, const gchar *device,
+ if (device == NULL)
+- return;
++ return FALSE;
+
+ proxy = connman_dbus_get_proxy(priv->store, device);
if (proxy == NULL)
- return;
+- return;
++ return FALSE;
- g_value_init(&value, G_TYPE_STRING);
- g_value_set_string(&value, policy);
@@ -485,43 +546,96 @@ index aad0a22..96f9388 100644
+ ret = connman_set_property(proxy, "IPv4.Configuration", &value, NULL);
g_object_unref(proxy);
++
++ return ret;
}
-@@ -389,26 +395,22 @@ static gboolean device_scan(GtkTreeModel *model, GtkTreePath *path,
- GtkTreeIter *iter, gpointer user_data)
+
+ void connman_client_set_powered(ConnmanClient *client, const gchar *device,
+@@ -385,98 +404,128 @@ void connman_client_set_powered(ConnmanClient *client, const gchar *device,
+ g_object_unref(proxy);
+ }
+
+-static gboolean device_scan(GtkTreeModel *model, GtkTreePath *path,
+- GtkTreeIter *iter, gpointer user_data)
++void connman_client_request_scan(ConnmanClient *client, char *scantype,
++ connman_request_scan_reply callback, gpointer userdata)
{
- DBusGProxy *proxy;
+- DBusGProxy *proxy;
- gboolean enabled;
++ ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client);
- gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy,
+- gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy,
- CONNMAN_COLUMN_ENABLED, &enabled, -1);
-+ -1);
++ DBG("client %p", client);
- if (proxy == NULL)
- return FALSE;
+- if (proxy == NULL)
+- return FALSE;
++ connman_request_scan_async(priv->manager, scantype, callback, userdata);
++}
- if (g_str_equal(dbus_g_proxy_get_interface(proxy),
+- if (g_str_equal(dbus_g_proxy_get_interface(proxy),
- CONNMAN_DEVICE_INTERFACE) == FALSE)
- return FALSE;
--
++gboolean connman_client_get_offline_status(ConnmanClient *client)
++{
++ GHashTable *hash;
++ GValue *value;
++ ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client);
++ gboolean ret;
+
- if (enabled == FALSE)
-+ CONNMAN_SERVICE_INTERFACE) == FALSE)
- return FALSE;
+- return FALSE;
++ DBG("client %p", client);
- connman_propose_scan(proxy, NULL);
+- connman_propose_scan(proxy, NULL);
++ ret = connman_get_properties(priv->manager, &hash, NULL);
- g_object_unref(proxy);
+- g_object_unref(proxy);
++ if (ret == FALSE)
++ goto done;
++
++ value = g_hash_table_lookup(hash, "OfflineMode");
++ ret = value ? g_value_get_boolean(value) : FALSE;
++
++done:
++ return ret;
- 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,
+-void connman_client_propose_scan(ConnmanClient *client, const gchar *device)
++void connman_client_set_offlinemode(ConnmanClient *client, gboolean status)
+ {
+ ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client);
+- DBusGProxy *proxy;
++ GValue value = { 0 };
+
+ DBG("client %p", client);
+
+- if (device == NULL) {
+- gtk_tree_model_foreach(GTK_TREE_MODEL(priv->store),
+- device_scan, NULL);
+- return;
+- }
+-
+- proxy = connman_dbus_get_proxy(priv->store, device);
+- if (proxy == NULL)
+- return;
+-
+- connman_propose_scan(proxy, NULL);
++ g_value_init(&value, G_TYPE_BOOLEAN);
++ g_value_set_boolean(&value, status);
+
+- g_object_unref(proxy);
++ connman_set_property(priv->manager, "OfflineMode", &value, NULL);
+ }
+
+ static gboolean network_disconnect(GtkTreeModel *model, GtkTreePath *path,
GtkTreeIter *iter, gpointer user_data)
{
DBusGProxy *proxy;
- gboolean enabled;
-+ gchar *name;
++ char *name;
+ guint type;
gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy,
@@ -600,20 +714,14 @@ index aad0a22..96f9388 100644
+ 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)
+@@ -487,32 +536,37 @@ static void connman_client_disconnect_all(ConnmanClient *client)
network_disconnect, NULL);
}
@@ -657,7 +765,7 @@ index aad0a22..96f9388 100644
DBG("client %p", client);
-@@ -548,56 +594,37 @@ gchar *connman_client_get_passphrase(ConnmanClient *client, const gchar *network
+@@ -548,41 +602,60 @@ gchar *connman_client_get_passphrase(ConnmanClient *client, const gchar *network
return passphrase;
}
@@ -682,51 +790,114 @@ index aad0a22..96f9388 100644
- 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);
--}
--
++ ret = connman_set_property(proxy, "Passphrase", &value, NULL);
+
+ g_value_unset(&value);
+
+ g_object_unref(proxy);
++done:
++ return ret;
+ }
+
-void connman_client_set_remember(ConnmanClient *client, const gchar *network,
- gboolean remember)
--{
-- ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client);
++void connman_client_set_callback(ConnmanClient *client,
++ ConnmanClientCallback callback, gpointer user_data)
+ {
+ 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;
--
++ gchar *state;
+
+ DBG("client %p", client);
+
++ priv->callback = callback;
++ priv->userdata = user_data;
++
++ g_object_set_data(G_OBJECT(priv->store), "callback", callback);
++ g_object_set_data(G_OBJECT(priv->store), "userdata", user_data);
++
++ state = g_object_get_data(G_OBJECT(priv->store), "State");
++ if (state != NULL && priv->callback != NULL)
++ priv->callback(state, priv->userdata);
++}
++
++void connman_client_remove(ConnmanClient *client, const gchar *network)
++{
++ ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client);
++ DBusGProxy *proxy;
++
+ if (network == NULL)
+ return;
+
+@@ -590,31 +663,46 @@ void connman_client_set_remember(ConnmanClient *client, const gchar *network,
+ if (proxy == NULL)
+ return;
+
- g_value_init(&value, G_TYPE_BOOLEAN);
- g_value_set_boolean(&value, remember);
--
++ connman_remove(proxy, NULL);
++
++ g_object_unref(proxy);
++}
++
++void connman_client_enable_technology(ConnmanClient *client, const char *network,
++ const gchar *technology)
++{
++ ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client);
++ DBusGProxy *proxy;
++ int ret;
+
- 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);
++ if (network== NULL)
++ return;
- g_value_unset(&value);
+- g_value_unset(&value);
++ proxy = connman_dbus_get_proxy(priv->store, network);
++ if (proxy == NULL)
++ return;
++
++ ret = connman_enable_technology(proxy, technology, NULL);
g_object_unref(proxy);
-+done:
-+ return ret;
}
- void connman_client_set_callback(ConnmanClient *client,
+-void connman_client_set_callback(ConnmanClient *client,
+- ConnmanClientCallback callback, gpointer user_data)
++void connman_client_disable_technology(ConnmanClient *client, const char *network,
++ const gchar *technology)
+ {
+ ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client);
+- gchar *state;
++ DBusGProxy *proxy;
++ int ret;
+
+- DBG("client %p", client);
+
+- priv->callback = callback;
+- priv->userdata = user_data;
++ if (network == NULL)
++ return;
+
+- g_object_set_data(G_OBJECT(priv->store), "callback", callback);
+- g_object_set_data(G_OBJECT(priv->store), "userdata", user_data);
++ proxy = connman_dbus_get_proxy(priv->store, network);
++ if (proxy == NULL)
++ return;
+
+- state = g_object_get_data(G_OBJECT(priv->store), "State");
+- if (state != NULL && priv->callback != NULL)
+- priv->callback(state, priv->userdata);
++ ret = connman_disable_technology(proxy, technology, NULL);
++
++ g_object_unref(proxy);
+ }
diff --git a/common/connman-client.h b/common/connman-client.h
-index f30dae4..f3ac1d3 100644
+index f30dae4..00c328a 100644
--- a/common/connman-client.h
+++ b/common/connman-client.h
@@ -23,6 +23,7 @@
@@ -778,15 +949,26 @@ index f30dae4..f3ac1d3 100644
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);
+@@ -81,37 +91,63 @@ 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,
++gboolean 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);
++void connman_client_remove(ConnmanClient *client, const gchar *network);
++
++void connman_client_request_scan(ConnmanClient *client, char *scantype,
++ connman_request_scan_reply callback, gpointer userdata);
++gboolean connman_client_get_offline_status(ConnmanClient *client);
++void connman_client_set_offlinemode(ConnmanClient *client, gboolean status);
++
++void connman_client_enable_technology(ConnmanClient *client, const char *network,
++ const gchar *technology);
++void connman_client_disable_technology(ConnmanClient *client, const char *network,
++ const gchar *technology);
enum {
CONNMAN_COLUMN_PROXY, /* G_TYPE_OBJECT */
+ CONNMAN_COLUMN_STATE, /* G_TYPE_STRING */
@@ -811,12 +993,29 @@ index f30dae4..f3ac1d3 100644
+ CONNMAN_COLUMN_ADDRESS, /* G_TYPE_STRING */
+ CONNMAN_COLUMN_NETMASK, /* G_TYPE_STRING */
+ CONNMAN_COLUMN_GATEWAY, /* G_TYPE_STRING */
++
++ CONNMAN_COLUMN_ETHERNET_ENABLED, /* G_TYPE_BOOLEAN */
++ CONNMAN_COLUMN_WIFI_ENABLED, /* G_TYPE_BOOLEAN */
++
++ CONNMAN_COLUMN_OFFLINEMODE, /* G_TYPE_BOOLEAN */
++
+ _CONNMAN_NUM_COLUMNS,
+
};
enum {
-@@ -108,10 +123,7 @@ enum {
+ CONNMAN_TYPE_UNKNOWN,
++
+ CONNMAN_TYPE_ETHERNET,
+ CONNMAN_TYPE_WIFI,
+ CONNMAN_TYPE_WIMAX,
+ CONNMAN_TYPE_BLUETOOTH,
++
++ CONNMAN_TYPE_LABEL_ETHERNET,
++ CONNMAN_TYPE_LABEL_WIFI,
++
++ CONNMAN_TYPE_SYSCONFIG,
++ _CONNMAN_NUM_TYPE,
};
enum {
@@ -829,25 +1028,38 @@ index f30dae4..f3ac1d3 100644
};
diff --git a/common/connman-dbus.c b/common/connman-dbus.c
-index 9eba7ae..83f4e57 100644
+index 9eba7ae..bf1778f 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);
+@@ -137,6 +137,27 @@ DBusGProxy *connman_dbus_get_proxy(GtkTreeStore *store, const gchar *path)
+ return proxy;
}
-+static gint compare_list(gchar *path_a, gchar *path_b, gpointer user_data)
++static gboolean compare_type(GtkTreeStore *store, GtkTreeIter *iter,
++ gconstpointer user_data)
+{
-+ return g_strcmp0(path_a, path_b);
++ guint type_target = GPOINTER_TO_UINT(user_data);
++ guint type;
++ gboolean found = FALSE;
++
++ gtk_tree_model_get(GTK_TREE_MODEL(store), iter,
++ CONNMAN_COLUMN_TYPE, &type, -1);
++
++ if (type != CONNMAN_TYPE_UNKNOWN)
++ found = (type == type_target);
++
++ return found;
+}
+
++static gboolean get_iter_from_type(GtkTreeStore *store, GtkTreeIter *iter, guint type)
++{
++ return iter_search(store, iter, NULL, compare_type, GUINT_TO_POINTER(type));
++}
+
- static void property_update(GtkTreeStore *store, const GValue *value,
- const char *key, connman_get_properties_reply callback)
+ gboolean connman_dbus_get_iter(GtkTreeStore *store, const gchar *path,
+ GtkTreeIter *iter)
{
-- GSList *list, *link, *old_list, *new_list = NULL;
-+ GSList *list, *link, *old_list, *new_list = NULL, *sorted_list = NULL;
- const char *iface;
+@@ -167,12 +188,7 @@ static void property_update(GtkTreeStore *store, const GValue *value,
DBG("store %p key %s", store, key);
@@ -857,25 +1069,11 @@ index 9eba7ae..83f4e57 100644
- iface = CONNMAN_DEVICE_INTERFACE;
- else
- iface = CONNMAN_NETWORK_INTERFACE;
-+ if (g_str_equal(key, "Services") == TRUE)
-+ iface = CONNMAN_SERVICE_INTERFACE;
++ 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,
+@@ -205,25 +221,12 @@ static void property_update(GtkTreeStore *store, const GValue *value,
for (list = old_list; list; list = list->next) {
gchar *path = list->data;
GtkTreeIter iter;
@@ -902,7 +1100,7 @@ index 9eba7ae..83f4e57 100644
g_free(path);
}
-@@ -263,48 +256,19 @@ static const gchar *type2icon(guint type)
+@@ -263,155 +266,115 @@ static const gchar *type2icon(guint type)
return NULL;
}
@@ -943,26 +1141,34 @@ index 9eba7ae..83f4e57 100644
-}
-
-static void network_changed(DBusGProxy *proxy, const char *property,
-+static void service_changed(DBusGProxy *proxy, const char *property,
- GValue *value, gpointer user_data)
+- GValue *value, gpointer user_data)
++static void enabled_technologies_changed(GtkTreeStore *store, GValue *value)
{
- GtkTreeStore *store = user_data;
- const char *path = dbus_g_proxy_get_path(proxy);
+- 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);
++ gboolean ethernet_enabled_prev, ethernet_enabled = FALSE;
++ gboolean wifi_enabled_prev, wifi_enabled = FALSE;
++ gchar **tech = g_value_get_boxed (value);
++ gint i;
++ gboolean ret;
-@@ -314,141 +278,92 @@ static void network_changed(DBusGProxy *proxy, const char *property,
- if (get_iter_from_path(store, &iter, path) == FALSE)
+- DBG("store %p proxy %p property %s", store, proxy, property);
+-
+- if (property == NULL || value == NULL)
++ if (value == NULL)
return;
+- if (get_iter_from_path(store, &iter, path) == FALSE)
+- return;
++ for (i = 0; i < g_strv_length (tech); i++)
++ {
++ if (g_str_equal("ethernet", *(tech + i)))
++ ethernet_enabled = TRUE;
++ else if (g_str_equal ("wifi", *(tech + i)))
++ wifi_enabled = TRUE;
++ }
+
- if (g_str_equal(property, "Connected") == TRUE) {
- gboolean connected = g_value_get_boolean(value);
- gtk_tree_store_set(store, &iter,
@@ -973,18 +1179,30 @@ index 9eba7ae..83f4e57 100644
- 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,
++ get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_ETHERNET);
++ gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
++ CONNMAN_COLUMN_ETHERNET_ENABLED, &ethernet_enabled_prev, -1);
++ if (ethernet_enabled_prev != ethernet_enabled)
+ 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_ETHERNET_ENABLED, ethernet_enabled, -1);
++
++ ret = get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_WIFI);
++ gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
++ CONNMAN_COLUMN_WIFI_ENABLED, &wifi_enabled_prev, -1);
++ if (wifi_enabled_prev != wifi_enabled)
+ gtk_tree_store_set(store, &iter,
- CONNMAN_COLUMN_STRENGTH, strength, -1);
- }
--}
--
++ CONNMAN_COLUMN_WIFI_ENABLED, wifi_enabled, -1);
+ }
+
-static void network_properties(DBusGProxy *proxy, GHashTable *hash,
- GError *error, gpointer user_data)
--{
++static void enabled_technologies_properties(GtkTreeStore *store, DBusGProxy *proxy, GValue *value)
+ {
- GtkTreeStore *store = user_data;
- GValue *value;
- const gchar *device, *name, *secret;
@@ -999,131 +1217,130 @@ index 9eba7ae..83f4e57 100644
-
- 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;
++ GtkTreeIter iter;
++ gboolean ethernet_enabled = FALSE;
++ gboolean wifi_enabled = FALSE;
++ gchar **tech = g_value_get_boxed (value);
++ gint i;
++
++ for (i = 0; i < g_strv_length (tech); i++)
++ {
++ if (g_str_equal("ethernet", *(tech + i)))
++ ethernet_enabled = TRUE;
++ else if (g_str_equal ("wifi", *(tech + i)))
++ wifi_enabled = TRUE;
++ }
- 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;
++ if (get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_ETHERNET) == FALSE)
++ gtk_tree_store_append(store, &iter, 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;
++ gtk_tree_store_set(store, &iter,
++ CONNMAN_COLUMN_PROXY, proxy,
++ CONNMAN_COLUMN_ETHERNET_ENABLED, ethernet_enabled,
++ CONNMAN_COLUMN_TYPE, CONNMAN_TYPE_LABEL_ETHERNET,
++ -1);
- 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;
++ if (get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_WIFI) == FALSE)
++ gtk_tree_store_append(store, &iter, NULL);
- value = g_hash_table_lookup(hash, "WiFi.Passphrase");
- secret = value ? g_value_get_string(value) : NULL;
--
++ gtk_tree_store_set(store, &iter,
++ CONNMAN_COLUMN_PROXY, proxy,
++ CONNMAN_COLUMN_WIFI_ENABLED, wifi_enabled,
++ CONNMAN_COLUMN_TYPE, CONNMAN_TYPE_LABEL_WIFI,
++ -1);
++}
+
- DBG("name %s strength %d", name, strength);
--
++static void offline_mode_changed(GtkTreeStore *store, GValue *value)
++{
++ GtkTreeIter iter;
++ gboolean offline_mode = g_value_get_boolean(value);
+
- if (get_iter_from_path(store, &parent, device) == FALSE)
- return;
--
++ get_iter_from_type(store, &iter, CONNMAN_TYPE_SYSCONFIG);
++ gtk_tree_store_set(store, &iter,
++ CONNMAN_COLUMN_OFFLINEMODE, offline_mode,
++ -1);
++}
+
- 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_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_SECURITY, security,
- CONNMAN_COLUMN_PASSPHRASE, secret, -1);
--
++static void offline_mode_properties(GtkTreeStore *store, DBusGProxy *proxy, GValue *value)
++{
++ GtkTreeIter iter;
++ gboolean offline_mode = g_value_get_boolean(value);
+
- 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,
+- 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_STRENGTH, strength,
- CONNMAN_COLUMN_SECURITY, security,
- CONNMAN_COLUMN_PASSPHRASE, secret, -1);
--
++ if (get_iter_from_type(store, &iter, CONNMAN_TYPE_SYSCONFIG) == FALSE)
++ gtk_tree_store_insert(store, &iter, NULL, 0);
+
-done:
- g_object_unref(proxy);
-+ -1);
-+ }
++ gtk_tree_store_set(store, &iter,
++ CONNMAN_COLUMN_PROXY, proxy,
++ CONNMAN_COLUMN_TYPE, CONNMAN_TYPE_SYSCONFIG,
++ CONNMAN_COLUMN_OFFLINEMODE, offline_mode,
++ -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)
++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;
-
-- 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;
+ GtkTreeIter iter;
+ GHashTable *ipv4;
++ const char *method, *addr, *netmask, *gateway;
+ GValue *ipv4_method, *ipv4_address, *ipv4_netmask, *ipv4_gateway;
-+ const gchar *method, *addr, *netmask, *gateway;
++
++ const char *state, *icon, *name, *security, *passphrase;
++ guint strength, type;
++
+
+ DBG("store %p proxy %p property %s", store, proxy, property);
+
+@@ -421,165 +384,167 @@ static void device_changed(DBusGProxy *proxy, const char *property,
+ if (get_iter_from_path(store, &iter, path) == FALSE)
+ return;
- if (g_str_equal(property, "Policy") == TRUE) {
- guint policy = get_policy(value);
@@ -1136,44 +1353,47 @@ index 9eba7ae..83f4e57 100644
- } 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;
+- GValue *value;
- const gchar *name, *icon;
- guint type, policy;
- gboolean powered;
- GtkTreeIter iter;
+-
+- DBG("store %p proxy %p hash %p", store, proxy, hash);
++ if (g_str_equal(property, "IPv4") == TRUE) {
- 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);
+- if (error != NULL || hash == NULL)
+- goto done;
+-
+- value = g_hash_table_lookup(hash, "Name");
+- name = value ? g_value_get_string(value) : NULL;
+-
+- value = g_hash_table_lookup(hash, "Type");
+- type = get_type(value);
+- icon = type2icon(type);
++ ipv4 = g_value_get_boxed (value);
++ if (!ipv4)
++ return;
- value = g_hash_table_lookup(hash, "Policy");
- policy = get_policy(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, "Powered");
- powered = 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;
+
- 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;
++ ipv4_netmask = g_hash_table_lookup (ipv4, "Netmask");
++ netmask = ipv4_netmask ? g_value_get_string(ipv4_netmask) : NULL;
- if (get_iter_from_proxy(store, &iter, proxy) == FALSE) {
- gtk_tree_store_insert_with_values(store, &iter, NULL, -1,
@@ -1183,16 +1403,37 @@ index 9eba7ae..83f4e57 100644
- CONNMAN_COLUMN_TYPE, type,
- CONNMAN_COLUMN_ENABLED, powered,
- CONNMAN_COLUMN_POLICY, policy, -1);
--
++ ipv4_gateway = g_hash_table_lookup (ipv4, "Gateway");
++ gateway = ipv4_gateway ? g_value_get_string(ipv4_gateway) : NULL;
+
- 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,
++ 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_ICON, icon,
-- CONNMAN_COLUMN_TYPE, type,
++ -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_ENABLED, powered,
- CONNMAN_COLUMN_POLICY, policy, -1);
-
@@ -1215,123 +1456,175 @@ index 9eba7ae..83f4e57 100644
-
- 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_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,
++ -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_ENABLED, enabled, -1);
-- } else if (g_str_equal(property, "Strength") == TRUE) {
++ CONNMAN_COLUMN_PASSPHRASE, passphrase,
++ -1);
+ } else if (g_str_equal(property, "Strength") == TRUE) {
- guint strength = g_value_get_uchar(value);
-- gtk_tree_store_set(store, &iter,
++ strength = value ? g_value_get_uchar(value) : 0;
+ gtk_tree_store_set(store, &iter,
- CONNMAN_COLUMN_STRENGTH, strength, -1);
-- }
--}
--
++ CONNMAN_COLUMN_STRENGTH, strength,
++ -1);
+ }
+ }
+
-static void connection_properties(DBusGProxy *proxy, GHashTable *hash,
-- GError *error, gpointer user_data)
--{
-- GtkTreeStore *store = user_data;
++static void service_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;
++
++ const char *state, *icon, *name, *security, *passphrase;
++ guint strength, type;
++
++ GHashTable *ipv4;
++ GValue *ipv4_method, *ipv4_address, *ipv4_netmask, *ipv4_gateway;
++ const char *method, *addr, *netmask, *gateway;
++
+ GtkTreeIter iter;
-- DBG("store %p proxy %p hash %p", store, proxy, hash);
-+ value = g_hash_table_lookup(hash, "IPv4.Configuration");
-+ ipv4 = g_value_get_boxed (value);
++ GValue *value;
++
+ DBG("store %p proxy %p hash %p", store, proxy, hash);
-- if (error != NULL || hash == NULL)
-+ if (!ipv4)
+ if (error != NULL || hash == NULL)
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, "State");
++ state = value ? g_value_get_string(value) : NULL;
++
++ value = g_hash_table_lookup(hash, "Name");
++ name = value ? g_value_get_string(value) : NULL;
++
+ value = g_hash_table_lookup(hash, "Type");
+ type = get_type(value);
++ icon = type2icon(type);
++
++ value = g_hash_table_lookup(hash, "Security");
++ security = value ? g_value_get_string(value) : NULL;
++
++ value = g_hash_table_lookup(hash, "PassPhrase");
++ passphrase = value ? g_value_get_string(value) : 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, "Strength");
+ strength = value ? g_value_get_uchar(value) : 0;
- 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.Configuration");
++ ipv4 = g_value_get_boxed (value);
- 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;
++ if (!ipv4)
++ goto done;
- DBG("type %d address %s", type, address);
-+ DBG("name %s type %d icon %s state %s", name, type, icon, state);
++ ipv4_method = g_hash_table_lookup (ipv4, "Method");
++ method = ipv4_method ? g_value_get_string(ipv4_method) : 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,
+- 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_TYPE, type,
- CONNMAN_COLUMN_ENABLED, enabled,
-+ CONNMAN_COLUMN_STATE, state,
-+ CONNMAN_COLUMN_SECURITY, security,
-+ CONNMAN_COLUMN_PASSPHRASE, passphrase,
- CONNMAN_COLUMN_STRENGTH, strength,
+- 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);
++ ipv4_address = g_hash_table_lookup (ipv4, "Address");
++ addr = ipv4_address ? g_value_get_string(ipv4_address) : NULL;
- dbus_g_proxy_add_signal(proxy, "PropertyChanged",
- G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(proxy, "PropertyChanged",
+- 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,
+- } else
+- gtk_tree_store_set(store, &iter,
+- CONNMAN_COLUMN_TYPE, type,
- CONNMAN_COLUMN_ENABLED, enabled,
- CONNMAN_COLUMN_STRENGTH, strength, -1);
--
++ ipv4_netmask = g_hash_table_lookup (ipv4, "Netmask");
++ netmask = ipv4_netmask ? g_value_get_string(ipv4_netmask) : NULL;
+
- value = g_hash_table_lookup(hash, "Device");
- device = value ? g_value_get_boxed(value) : NULL;
--
++ ipv4_gateway = g_hash_table_lookup (ipv4, "Gateway");
++ gateway = ipv4_gateway ? g_value_get_string(ipv4_gateway) : NULL;
+
- DBG("device %s", device);
--
++ DBG("name %s type %d icon %s state %s", name, type, icon, state);
+
- gtk_tree_store_set(store, &iter, CONNMAN_COLUMN_DEVICE, device, -1);
--
++ if (get_iter_from_proxy(store, &iter, proxy) == FALSE) {
++ GtkTreeIter label_iter;
++ guint label_type;
+
- 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);
++ switch (type) {
++ case CONNMAN_TYPE_ETHERNET:
++ label_type = CONNMAN_TYPE_LABEL_ETHERNET;
++ break;
++ case CONNMAN_TYPE_WIFI:
++ label_type = CONNMAN_TYPE_LABEL_WIFI;
++ break;
++ default:
++ label_type = CONNMAN_TYPE_UNKNOWN;
++ break;
++ }
++
++ get_iter_from_type(store, &label_iter, label_type);
++
++ gtk_tree_store_insert_after(store, &iter, NULL, &label_iter);
++
++ 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(service_changed), store, NULL);
+ }
++ gtk_tree_store_set(store, &iter,
++ CONNMAN_COLUMN_PROXY, proxy,
++ CONNMAN_COLUMN_NAME, name,
++ CONNMAN_COLUMN_ICON, icon,
++ CONNMAN_COLUMN_TYPE, type,
++ 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,
+ }
+@@ -594,25 +559,12 @@ static void manager_changed(DBusGProxy *proxy, const char *property,
if (property == NULL || value == NULL)
return;
@@ -1356,10 +1649,14 @@ index 9eba7ae..83f4e57 100644
- property_update(store, value, property, device_properties);
+ if (g_str_equal(property, "Services") == TRUE) {
+ property_update(store, value, property, service_properties);
++ } else if (g_str_equal(property, "EnabledTechnologies") == TRUE) {
++ enabled_technologies_changed(store, value);
++ } else if (g_str_equal(property, "OfflineMode") == TRUE) {
++ offline_mode_changed(store, value);
}
}
-@@ -620,31 +458,16 @@ static void manager_properties(DBusGProxy *proxy, GHashTable *hash,
+@@ -620,31 +572,24 @@ static void manager_properties(DBusGProxy *proxy, GHashTable *hash,
GError *error, gpointer user_data)
{
GtkTreeStore *store = user_data;
@@ -1379,39 +1676,59 @@ index 9eba7ae..83f4e57 100644
- callback = g_object_get_data(G_OBJECT(store), "callback");
- if (callback)
- callback(state, NULL);
--
++ value = g_hash_table_lookup(hash, "Services");
++ if (value != NULL)
++ property_update(store, value, "Services", service_properties);
+
- value = g_hash_table_lookup(hash, "Devices");
-- if (value != NULL)
++ value = g_hash_table_lookup(hash, "EnabledTechnologies");
+ if (value != NULL)
- property_update(store, value, "Devices", device_properties);
--
++ enabled_technologies_properties(store, proxy, value);
+
- value = g_hash_table_lookup(hash, "Connections");
-+ value = g_hash_table_lookup(hash, "Services");
++ value = g_hash_table_lookup(hash, "OfflineMode");
if (value != NULL)
- property_update(store, value,
- "Connections", connection_properties);
-+ property_update(store, value, "Services", service_properties);
++ offline_mode_properties(store, proxy, value);
}
DBusGProxy *connman_dbus_create_manager(DBusGConnection *conn,
diff --git a/common/connman-dbus.h b/common/connman-dbus.h
-index a9fa51c..47179da 100644
+index a9fa51c..dc07650 100644
--- a/common/connman-dbus.h
+++ b/common/connman-dbus.h
-@@ -30,10 +30,10 @@
- #define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager"
+@@ -31,7 +31,7 @@
#define CONNMAN_MANAGER_PATH "/"
--#define CONNMAN_PROFILE_INTERFACE CONNMAN_SERVICE ".Profile"
+ #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);
+ #define CONNMAN_NETWORK_INTERFACE CONNMAN_SERVICE ".Network"
+ #define CONNMAN_CONNECTION_INTERFACE CONNMAN_SERVICE ".Connection"
+
+diff --git a/common/connman-dbus.xml b/common/connman-dbus.xml
+index 9fefd55..e20cb3b 100644
+--- a/common/connman-dbus.xml
++++ b/common/connman-dbus.xml
+@@ -15,5 +15,16 @@
+ </method>
+ <method name="Disconnect">
+ </method>
++ <method name="Remove">
++ </method>
++ <method name="RequestScan">
++ <arg type="s"/>
++ </method>
++ <method name="EnableTechnology">
++ <arg type="s"/>
++ </method>
++ <method name="DisableTechnology">
++ <arg type="s"/>
++ </method>
+ </interface>
+ </node>
diff --git a/common/demo.c b/common/demo.c
deleted file mode 100644
index 5e3924f..0000000
@@ -2451,7 +2768,7 @@ index 1eb1c3d..0000000
- data->dialog = dialog;
-}
diff --git a/properties/advanced.h b/properties/advanced.h
-index f85f10d..a180b98 100644
+index f85f10d..42b439f 100644
--- a/properties/advanced.h
+++ b/properties/advanced.h
@@ -23,6 +23,7 @@ struct config_data {
@@ -2462,11 +2779,13 @@ index f85f10d..a180b98 100644
GtkWidget *title;
GtkWidget *label;
GtkWidget *button;
-@@ -45,15 +46,26 @@ struct config_data {
+@@ -45,15 +46,34 @@ struct config_data {
GtkWidget *value[3];
GtkWidget *entry[3];
} ipv4;
-+
+-};
+
+-void create_advanced_dialog(struct config_data *data, guint type);
+ struct ipv4_config ipv4_config;
+
+ struct {
@@ -2478,25 +2797,32 @@ index f85f10d..a180b98 100644
+ 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);
++ GtkWidget *ethernet_button;
++ GtkWidget *wifi_button;
-void add_wifi_policy(GtkWidget *mainbox, struct config_data *data);
++ GtkWidget *scan_button;
++ GtkWidget *offline_button;
++};
++
++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, 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);
++void add_ethernet_switch_button(GtkWidget *mainbox, GtkTreeIter *iter,
++ struct config_data *data);
++
++void add_wifi_switch_button(GtkWidget *mainbox, GtkTreeIter *iter,
++ struct config_data *data);
diff --git a/properties/ethernet.c b/properties/ethernet.c
-index d5c948d..1901ee6 100644
+index d5c948d..d443ca1 100644
--- a/properties/ethernet.c
+++ b/properties/ethernet.c
@@ -23,6 +23,7 @@
@@ -2507,7 +2833,7 @@ index d5c948d..1901ee6 100644
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-@@ -30,93 +31,167 @@
+@@ -30,93 +31,220 @@
#include "advanced.h"
@@ -2562,17 +2888,68 @@ index d5c948d..1901ee6 100644
+ 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 switch_callback(GtkWidget *editable, gpointer user_data)
++{
++ struct config_data *data = user_data;
++ const gchar *label = gtk_button_get_label(GTK_BUTTON(data->ethernet_button));
++ if (g_str_equal(label, "Disable"))
++ connman_client_disable_technology(data->client, data->device, "ethernet");
++ else if (g_str_equal(label, "Enable"))
++ connman_client_enable_technology(data->client, data->device, "ethernet");
}
-void add_ethernet_policy(GtkWidget *mainbox, struct config_data *data)
++void add_ethernet_switch_button(GtkWidget *mainbox, GtkTreeIter *iter,
++ struct config_data *data)
++{
++ GtkWidget *vbox;
++ GtkWidget *table;
++ GtkWidget *label;
++ GtkWidget *buttonbox;
++ GtkWidget *button;
++ gboolean ethernet_enabled;
++
++ gtk_tree_model_get(data->model, iter,
++ CONNMAN_COLUMN_ETHERNET_ENABLED, &ethernet_enabled,
++ -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(1, 1, 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(_("Enable/Disable Wired Networks."));
++ gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
++
++ buttonbox = gtk_hbutton_box_new();
++ gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonbox), GTK_BUTTONBOX_CENTER);
++ gtk_box_pack_start(GTK_BOX(mainbox), buttonbox, FALSE, FALSE, 0);
++
++ button = gtk_button_new();
++ data->ethernet_button = button;
++
++ if (ethernet_enabled)
++ gtk_button_set_label(GTK_BUTTON(button), _("Disable"));
++ else
++ gtk_button_set_label(GTK_BUTTON(button), _("Enable"));
++
++ gtk_container_add(GTK_CONTAINER(buttonbox), button);
++ g_signal_connect(G_OBJECT(button), "clicked",
++ G_CALLBACK(switch_callback), 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;
+
@@ -2589,7 +2966,8 @@ index d5c948d..1901ee6 100644
+ CONNMAN_COLUMN_NETMASK, &ipv4_config.netmask,
+ CONNMAN_COLUMN_GATEWAY, &ipv4_config.gateway,
+ -1);
-+
+
+- vbox = gtk_vbox_new(FALSE, 0);
+ 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);
@@ -2725,7 +3103,7 @@ index d5c948d..1901ee6 100644
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)
+@@ -124,9 +252,5 @@ void update_ethernet_policy(struct config_data *data, guint policy)
}
g_signal_handlers_unblock_by_func(G_OBJECT(combo),
@@ -2737,22 +3115,24 @@ index d5c948d..1901ee6 100644
+ G_CALLBACK(changed_callback), data);
}
diff --git a/properties/main.c b/properties/main.c
-index 01439e6..3701f16 100644
+index 01439e6..6b389bc 100644
--- a/properties/main.c
+++ b/properties/main.c
-@@ -33,102 +33,54 @@
+@@ -32,103 +32,139 @@
+
static ConnmanClient *client;
static GtkWidget *interface_notebook;
++static struct config_data *current_data;
-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,
++static void status_update(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) {
@@ -2760,60 +3140,91 @@ index 01439e6..3701f16 100644
- info = g_strdup_printf(_("%s is currently active "
- "and has the IP address %s."),
- N_("Ethernet"), address);
+- } else {
+- str = N_("Cable Unplugged");
+- info = g_strdup_printf(_("The cable for %s is "
+- "not plugged in."), N_("Ethernet"));
+- }
+- break;
+ 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,
++ guint type;
++ const char *name = NULL, *_name = NULL, *state = NULL;
++ gboolean ethernet_enabled;
++ gboolean wifi_enabled;
++ gboolean offline_mode;
+
+- 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;
++ gtk_tree_model_get(model, iter,
+ CONNMAN_COLUMN_STATE, &state,
+ CONNMAN_COLUMN_NAME, &name,
+ CONNMAN_COLUMN_TYPE, &type,
++ CONNMAN_COLUMN_ETHERNET_ENABLED, &ethernet_enabled,
++ CONNMAN_COLUMN_WIFI_ENABLED, &wifi_enabled,
++ CONNMAN_COLUMN_OFFLINEMODE, &offline_mode,
+ -1);
+
-+ if (name && _name && g_str_equal(name, _name) == TRUE && data->connecting) {
++ if (type == CONNMAN_TYPE_WIFI) {
++ if (data->wifi.name)
++ _name = gtk_label_get_text(GTK_LABEL(data->wifi.name));
++
++ if (!(name && _name && g_str_equal(name, _name)))
++ return;
+
+- default:
+- if (inrange == TRUE)
+- str = N_("Connected");
+ 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"));
++ } else {
+ 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
++ }
++ } else if (type == CONNMAN_TYPE_LABEL_ETHERNET) {
++ if (!data->ethernet_button)
++ return;
++ if (ethernet_enabled)
++ gtk_button_set_label(GTK_BUTTON(data->ethernet_button), _("Disable"));
+ else
- str = N_("Not Connected");
- break;
++ gtk_button_set_label(GTK_BUTTON(data->ethernet_button), _("Enable"));
++ } else if (type == CONNMAN_TYPE_LABEL_WIFI) {
++ if (!data->wifi_button)
++ return;
++ if (wifi_enabled) {
++ gtk_button_set_label(GTK_BUTTON(data->wifi_button), _("Disable"));
++ gtk_widget_set_sensitive(data->scan_button, 1);
++ } else {
++ gtk_button_set_label(GTK_BUTTON(data->wifi_button), _("Enable"));
++ gtk_widget_set_sensitive(data->scan_button, 0);
++ }
++ } else if (type == CONNMAN_TYPE_SYSCONFIG) {
++ if (!data->offline_button)
++ return;
++ if (offline_mode)
++ gtk_button_set_label(GTK_BUTTON(data->offline_button), _("OnlineMode"));
++ else
++ gtk_button_set_label(GTK_BUTTON(data->offline_button), _("OfflineMode"));
}
--
++}
+
- markup = g_strdup_printf("<b>%s</b>", str);
- gtk_label_set_markup(GTK_LABEL(data->title), markup);
- g_free(markup);
@@ -2832,30 +3243,72 @@ index 01439e6..3701f16 100644
- default:
- break;
- }
--}
--
++static void set_offline_callback(GtkWidget *button, gpointer user_data)
++{
++ struct config_data *data = user_data;
++ const gchar *label = gtk_button_get_label(GTK_BUTTON(data->offline_button));
++ if (g_str_equal(label, "OnlineMode"))
++ connman_client_set_offlinemode(client, 0);
++ else if (g_str_equal(label, "OfflineMode"))
++ connman_client_set_offlinemode(client, 1);
+ }
+
-static void update_config(struct config_data *data)
--{
++static void add_system_config(GtkWidget *mainbox, GtkTreeIter *iter,
++ struct config_data *data)
+ {
- GtkTreeIter iter;
- guint type;
- gchar *network;
--
++ GtkWidget *vbox;
++ GtkWidget *table;
++ GtkWidget *label;
++ GtkWidget *buttonbox;
++ GtkWidget *button;
++ gboolean offline_mode;
+
- if (gtk_tree_model_get_iter_from_string(data->model,
- &iter, data->index) == FALSE)
- return;
--
++ 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);
+
- gtk_tree_model_get(data->model, &iter,
- CONNMAN_COLUMN_TYPE, &type,
- CONNMAN_COLUMN_NAME, &network, -1);
--
++ table = gtk_table_new(1, 1, 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);
+
- g_free(network);
-}
--
++ label = gtk_label_new(_("System Configuration"));
++ gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
+
-static void advanced_callback(GtkWidget *button, gpointer user_data)
-{
- struct config_data *data = user_data;
--
++ buttonbox = gtk_hbutton_box_new();
++ gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonbox), GTK_BUTTONBOX_CENTER);
++ gtk_box_pack_start(GTK_BOX(mainbox), buttonbox, FALSE, FALSE, 0);
++
++ gtk_tree_model_get(data->model, iter,
++ CONNMAN_COLUMN_OFFLINEMODE, &offline_mode,
++ -1);
++
++ button = gtk_button_new();
++ data->offline_button = button;
++ if (offline_mode)
++ gtk_button_set_label(GTK_BUTTON(button), _("OnlineMode"));
++ else
++ gtk_button_set_label(GTK_BUTTON(button), _("OfflineMode"));
+
- gtk_widget_show_all(data->dialog);
++ gtk_container_add(GTK_CONTAINER(buttonbox), button);
++ g_signal_connect(G_OBJECT(button), "clicked",
++ G_CALLBACK(set_offline_callback), data);
}
static struct config_data *create_config(GtkTreeModel *model,
@@ -2873,12 +3326,11 @@ index 01439e6..3701f16 100644
- gchar *markup, *vendor = NULL, *product = NULL;
- gchar *network = NULL, *address = NULL;
+ guint type;
-+ gchar *vendor = NULL, *product = NULL;
-+ gchar *address = NULL, *state = NULL;
++ char *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,
+@@ -137,15 +173,10 @@ static struct config_data *create_config(GtkTreeModel *model,
data->client = client;
gtk_tree_model_get(model, iter,
@@ -2888,24 +3340,25 @@ index 01439e6..3701f16 100644
- CONNMAN_COLUMN_NETWORK, &network,
- CONNMAN_COLUMN_ADDRESS, &address,
- CONNMAN_COLUMN_POLICY, &policy, -1);
+-
+- data->device = g_strdup(dbus_g_proxy_get_path(proxy));
+- g_object_unref(proxy);
+ 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,
+ data->widget = mainbox;
+@@ -163,12 +194,27 @@ 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;
++ data->model = model;
++ data->index = gtk_tree_model_get_string_from_iter(model, iter);
++ data->device = g_strdup(dbus_g_proxy_get_path(proxy));
++ g_object_unref(proxy);
+
switch (type) {
case CONNMAN_TYPE_ETHERNET:
@@ -2915,10 +3368,19 @@ index 01439e6..3701f16 100644
case CONNMAN_TYPE_WIFI:
- add_wifi_policy(mainbox, data);
+ add_wifi_policy(mainbox, iter, data);
++ break;
++ case CONNMAN_TYPE_LABEL_ETHERNET:
++ add_ethernet_switch_button(mainbox, iter, data);
++ break;
++ case CONNMAN_TYPE_LABEL_WIFI:
++ add_wifi_switch_button(mainbox, iter, data);
++ break;
++ case CONNMAN_TYPE_SYSCONFIG:
++ add_system_config(mainbox, iter, data);
break;
default:
break;
-@@ -183,32 +139,12 @@ static struct config_data *create_config(GtkTreeModel *model,
+@@ -183,34 +229,10 @@ 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);
@@ -2941,19 +3403,21 @@ index 01439e6..3701f16 100644
- update_status(data, type, inrange, policy, network, address);
-
- g_free(network);
- g_free(address);
-
+- g_free(address);
+-
- data->model = model;
- data->index = gtk_tree_model_get_string_from_iter(model, iter);
-
gtk_widget_show_all(mainbox);
+- g_free(product);
+- g_free(vendor);
+ g_signal_connect(G_OBJECT(model), "row-changed",
-+ G_CALLBACK(get_state_realtime), data);
- g_free(product);
- g_free(vendor);
++ G_CALLBACK(status_update), data);
-@@ -230,67 +166,56 @@ static void select_callback(GtkTreeSelection *selection, gpointer user_data)
+ return data;
+ }
+@@ -230,112 +252,108 @@ static void select_callback(GtkTreeSelection *selection, gpointer user_data)
return;
}
@@ -2961,42 +3425,50 @@ index 01439e6..3701f16 100644
- data = create_config(model, &iter, user_data);
- if (data == NULL)
- return;
--
++ if (current_data) {
++ g_signal_handlers_disconnect_by_func(G_OBJECT(model),
++ G_CALLBACK(status_update), current_data);
++ g_free(current_data);
++ }
++ 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);
--
++ current_data = 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);
++ 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;
++static void device_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell,
++ GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
+ {
+ guint type;
- gboolean powered, inrange;
--
-- gtk_tree_model_get(model, iter, CONNMAN_COLUMN_TYPE, &type,
++ char *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);
-}
-
-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);
@@ -3005,36 +3477,17 @@ index 01439e6..3701f16 100644
- 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;
+-{
+- 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,
+-
+- gtk_tree_model_get(model, iter, CONNMAN_COLUMN_TYPE, &type,
- CONNMAN_COLUMN_ENABLED, &powered,
- CONNMAN_COLUMN_INRANGE, &inrange, -1);
+ CONNMAN_COLUMN_NAME, &name,
@@ -3044,70 +3497,102 @@ index 01439e6..3701f16 100644
switch (type) {
case CONNMAN_TYPE_ETHERNET:
title = N_("Ethernet");
++ markup = g_strdup_printf(" %s\n", title);
break;
case CONNMAN_TYPE_WIFI:
- title = N_("Wireless");
+ /* Show the AP name */
+ title = N_(name);
++ 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
++ state = "";
++ markup = g_strdup_printf(" %s\n %s", title, state);
++
break;
case CONNMAN_TYPE_WIMAX:
title = N_("WiMAX");
-@@ -303,21 +228,27 @@ static void type_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell,
++ markup = g_strdup_printf(" %s\n", title);
+ break;
+ case CONNMAN_TYPE_BLUETOOTH:
+ title = N_("Bluetooth");
++ markup = g_strdup_printf(" %s\n", title);
++ break;
++ case CONNMAN_TYPE_LABEL_ETHERNET:
++ title = N_("Wired Networks");
++ markup = g_strdup_printf("<b>\n%s\n</b>", title);
++ break;
++ case CONNMAN_TYPE_LABEL_WIFI:
++ title = N_("Wireless Networks");
++ markup = g_strdup_printf("<b>\n%s\n</b>", title);
++ break;
++ case CONNMAN_TYPE_SYSCONFIG:
++ title = N_("System Configuration");
++ markup = g_strdup_printf("<b>\n%s\n</b>", title);
+ break;
+ default:
+ title = N_("Unknown");
++ markup = g_strdup_printf(" %s\n", title);
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
+- else
- info = N_("Not Connected");
-+ state = "";
-+ markup = g_strdup_printf("<b>%s</b>\n%s\n", title, state);
- } else
+- } 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);
+- 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;
+- guint type;
++ guint type, strength;
++ char *name;
+
+- gtk_tree_model_get(model, iter, CONNMAN_COLUMN_TYPE, &type, -1);
++ gtk_tree_model_get(model, iter, CONNMAN_COLUMN_TYPE, &type,
++ CONNMAN_COLUMN_STRENGTH, &strength,
++ -1);
-@@ -326,16 +257,16 @@ static void type_to_icon(GtkTreeViewColumn *column, GtkCellRenderer *cell,
switch (type) {
- case CONNMAN_TYPE_ETHERNET:
+- case CONNMAN_TYPE_ETHERNET:
++ case CONNMAN_TYPE_WIFI:
++ name = g_strdup_printf("connman-signal-0%d", (strength-1)/20+1);
++ g_object_set(cell, "icon-name", name,
++ "stock-size", 4, NULL);
++ break;
++ case CONNMAN_TYPE_LABEL_ETHERNET:
g_object_set(cell, "icon-name", "network-wired",
- "stock-size", 5, NULL);
-+ "stock-size", 5, NULL);
++ "stock-size", 4, NULL);
break;
- case CONNMAN_TYPE_WIFI:
- case CONNMAN_TYPE_WIMAX:
+- case CONNMAN_TYPE_WIFI:
+- case CONNMAN_TYPE_WIMAX:
++ case CONNMAN_TYPE_LABEL_WIFI:
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",
+- break;
+- case CONNMAN_TYPE_BLUETOOTH:
+- g_object_set(cell, "icon-name", "bluetooth",
- "stock-size", 5, NULL);
-+ "stock-size", 5, NULL);
++ "stock-size", 4, NULL);
break;
default:
g_object_set(cell, "icon-name", NULL, NULL);
-@@ -362,9 +293,9 @@ static GtkWidget *create_interfaces(GtkWidget *window)
+@@ -362,40 +380,34 @@ static GtkWidget *create_interfaces(GtkWidget *window)
scrolled = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
@@ -3119,7 +3604,18 @@ index 01439e6..3701f16 100644
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_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_widget_set_size_request(tree, 180, -1);
++ gtk_widget_set_size_request(tree, 220, -1);
+ gtk_container_add(GTK_CONTAINER(scrolled), tree);
+
+
+ column = gtk_tree_view_column_new();
+ gtk_tree_view_column_set_expand(column, TRUE);
+ gtk_tree_view_column_set_spacing(column, 4);
++ gtk_tree_view_column_set_alignment(column, 0);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
renderer = gtk_cell_renderer_pixbuf_new();
@@ -3127,28 +3623,30 @@ index 01439e6..3701f16 100644
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();
++ type_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();
+-
+- 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)
+@@ -405,21 +417,19 @@ static GtkWidget *create_interfaces(GtkWidget *window)
+
+ model = connman_client_get_device_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);
g_signal_connect(G_OBJECT(selection), "changed",
@@ -3167,7 +3665,7 @@ index 01439e6..3701f16 100644
{
gtk_widget_destroy(window);
-@@ -451,7 +377,7 @@ static GtkWidget *create_window(void)
+@@ -451,7 +461,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",
@@ -3176,7 +3674,7 @@ index 01439e6..3701f16 100644
vbox = gtk_vbox_new(FALSE, 12);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
-@@ -467,12 +393,12 @@ static GtkWidget *create_window(void)
+@@ -467,12 +477,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",
@@ -3191,8 +3689,17 @@ index 01439e6..3701f16 100644
gtk_widget_show_all(window);
+@@ -487,6 +497,8 @@ int main(int argc, char *argv[])
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ textdomain(GETTEXT_PACKAGE);
+
++ current_data = NULL;
++
+ gtk_init(&argc, &argv);
+
+ gtk_window_set_default_icon_name("network-wireless");
diff --git a/properties/wifi.c b/properties/wifi.c
-index 320dce4..3d3cee8 100644
+index 320dce4..42fe7d2 100644
--- a/properties/wifi.c
+++ b/properties/wifi.c
@@ -23,6 +23,7 @@
@@ -3228,7 +3735,7 @@ index 320dce4..3d3cee8 100644
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)
+@@ -37,98 +56,357 @@ static void changed_callback(GtkWidget *editable, gpointer user_data)
active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->policy.config));
@@ -3251,92 +3758,163 @@ index 320dce4..3d3cee8 100644
+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));
++ char *passphrase;
++ passphrase = (gchar *)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);
++ if (ret == FALSE) {
++ return;
++ }
+ }
+
+ 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;
++ ret = connman_client_set_ipv4(data->client, data->device, &data->ipv4_config);
++ if (ret == FALSE) {
++ return;
++ }
+
-+ connman_client_set_ipv4(data->client, data->device, &data->ipv4_config);
++ connman_client_connect_async(data->client, data->device, connect_reply_cb, data);
+ }
+
+-void add_wifi_policy(GtkWidget *mainbox, struct config_data *data)
++static void disconnect_callback(GtkWidget *editable, gpointer user_data)
++{
++ struct config_data *data = user_data;
+
++ connman_client_disconnect(data->client, data->device);
+}
+
-+static void disconnect_callback(GtkWidget *editable, gpointer user_data)
++static void switch_callback(GtkWidget *editable, gpointer user_data)
+{
+ struct config_data *data = user_data;
-+ gboolean ret;
++ const gchar *label = gtk_button_get_label(GTK_BUTTON(data->wifi_button));
+
-+ data->connecting = 0;
++ if (g_str_equal(label, "Disable"))
++ connman_client_disable_technology(data->client, data->device, "wifi");
++ else
++ connman_client_enable_technology(data->client, data->device, "wifi");
++}
+
-+ 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)
++static void scan_reply_cb(DBusGProxy *proxy, GError *error,
++ gpointer user_data)
++{
++ GtkWidget *button = user_data;
++ gtk_widget_set_sensitive(button, 1);
++
++ if (error)
++ g_error_free(error);
++}
++
++static void scan_callback(GtkWidget *button, gpointer user_data)
++{
++ struct config_data *data = user_data;
++ gtk_widget_set_sensitive(button, 0);
++ connman_client_request_scan(data->client, "", scan_reply_cb, button);
++}
++
++void add_wifi_switch_button(GtkWidget *mainbox, GtkTreeIter *iter,
++ struct config_data *data)
{
GtkWidget *vbox;
-- GtkWidget *table;
-+ GtkWidget *dialog;
-+ GtkWidget *entry;
+ GtkWidget *table;
GtkWidget *label;
- GtkWidget *combo;
+- GtkWidget *combo;
+ GtkWidget *buttonbox;
+ GtkWidget *button;
-+ DBusGProxy *proxy;
++ gboolean wifi_enabled;
- 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);
++ gtk_tree_model_get(data->model, iter,
++ CONNMAN_COLUMN_WIFI_ENABLED, &wifi_enabled,
++ -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(1, 1, 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);
+
+-#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);
++ label = gtk_label_new(_("Configure Wifi Networks."));
+ 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), "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, 4, 0, 1);
+- data->policy.config = combo;
+-#endif
++ buttonbox = gtk_hbutton_box_new();
++ gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonbox), GTK_BUTTONBOX_CENTER);
++ gtk_box_pack_start(GTK_BOX(mainbox), buttonbox, FALSE, FALSE, 0);
++
++ button = gtk_button_new();
++ data->wifi_button = button;
++
++ if (wifi_enabled)
++ gtk_button_set_label(GTK_BUTTON(button), _("Disable"));
++ else
++ gtk_button_set_label(GTK_BUTTON(button), _("Enable"));
++
++ gtk_container_add(GTK_CONTAINER(buttonbox), button);
++ g_signal_connect(G_OBJECT(button), "clicked",
++ G_CALLBACK(switch_callback), data);
++
++ button = gtk_button_new_with_label(_("Scan"));
++ data->scan_button = button;
++
++ if (!wifi_enabled)
++ gtk_widget_set_sensitive(button, 0);
++
++ gtk_container_add(GTK_CONTAINER(buttonbox), button);
++ g_signal_connect(G_OBJECT(button), "clicked",
++ G_CALLBACK(scan_callback), data);
++}
++
++
++static void wifi_ipconfig(GtkWidget *table, struct config_data *data, GtkTreeIter *iter)
++{
++ GtkWidget *entry;
++ GtkWidget *label;
++ GtkWidget *combo;
++ DBusGProxy *proxy;
++
+ 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,
@@ -3345,19 +3923,16 @@ index 320dce4..3d3cee8 100644
+ CONNMAN_COLUMN_GATEWAY, &ipv4_config.gateway,
+ -1);
--#if 0
-- label = gtk_label_new(_("Network Name:"));
+ 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(_("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), "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_append_text(GTK_COMBO_BOX(combo), "DHCP");
@@ -3369,27 +3944,13 @@ index 320dce4..3d3cee8 100644
+
+ 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(NULL);
+- gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+ 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)
@@ -3399,12 +3960,8 @@ index 320dce4..3d3cee8 100644
+
+ 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)
@@ -3414,8 +3971,6 @@ index 320dce4..3d3cee8 100644
+
+ 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();
@@ -3454,7 +4009,7 @@ index 320dce4..3d3cee8 100644
+ GtkWidget *entry;
+ GtkWidget *button;
+
-+ const gchar *name, *security, *icon, *state;
++ const char *name, *security, *icon, *state;
+ guint strength;
+
+ gtk_tree_model_get(data->model, iter,
@@ -3465,6 +4020,9 @@ index 320dce4..3d3cee8 100644
+ CONNMAN_COLUMN_STRENGTH, &strength,
+ -1);
+
++ if (g_str_equal(state, "failure") == TRUE)
++ connman_client_remove(data->client, data->device);
++
+ 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);
@@ -3475,31 +4033,24 @@ index 320dce4..3d3cee8 100644
+
+ 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_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_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) {
@@ -3532,7 +4083,9 @@ index 320dce4..3d3cee8 100644
- data->policy.label = label;
+ gtk_widget_hide(label);
+ data->wifi.connect_info = label;
-+
+
+- g_signal_connect(G_OBJECT(combo), "changed",
+- G_CALLBACK(changed_callback), data);
+ 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",
@@ -3557,17 +4110,14 @@ index 320dce4..3d3cee8 100644
+ }
+
+ 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;
+- gchar *info = NULL;
+ GtkWidget *entry[3];
- gchar *info = NULL;
+ int i;
+
+ for (i = 0; i < 3; i++)
@@ -3599,14 +4149,14 @@ index 320dce4..3d3cee8 100644
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)
+@@ -136,9 +414,5 @@ 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_free(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
index 6958ee57b..766004811 100644
--- a/meta/recipes-connectivity/connman/connman-gnome_0.5.bb
+++ b/meta/recipes-connectivity/connman/connman-gnome_0.5.bb
@@ -6,7 +6,7 @@ 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"
+PR = "r1"
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"