This email list is read-only. Emails sent to this list will be discarded ---------------------------------- ChangeLog | 11 +++ applet/main.c | 121 ++++++++++++++++++++++++++++--- applet/status.c | 35 +++++++++ applet/status.h | 1 + common/connman-client.c | 64 +++++++++++++++-- common/connman-client.h | 3 + common/connman-dbus.c | 32 ++++++++- configure.ac | 2 +- icons/Makefile.am | 3 +- icons/connman-notifier-unavailable.png | Bin 0 -> 664 bytes properties/main.c | 2 +- 11 files changed, 252 insertions(+), 22 deletions(-)
New commits: commit 7b3640c65292e333b5c37111cc556ef928b7a014 Author: Marcel Holtmann <[email protected]> Date: Thu Jan 22 19:27:49 2009 +0100 Release 0.3 commit 325cc060e5a4d0b6f34e06c0d3e376369864696d Author: Marcel Holtmann <[email protected]> Date: Wed Jan 21 22:01:43 2009 +0100 Update device status on disconnect commit f459795f3c8012327976292f4d7ac0b85d75d813 Author: Marcel Holtmann <[email protected]> Date: Wed Jan 21 21:24:17 2009 +0100 Hide known networks that are not in range commit 34e6d95d9f9a70397c2fb33561d1b49c7b934dd9 Author: Marcel Holtmann <[email protected]> Date: Wed Jan 21 20:45:06 2009 +0100 Hide menu when daemon is not available commit f8093ac16f4abe53174036e9e7f81f69c8b0673f Author: Marcel Holtmann <[email protected]> Date: Wed Jan 21 20:38:21 2009 +0100 Fix typo with device property name commit 7760658b39c144108faf0d18c20d4001f2220eae Author: Marcel Holtmann <[email protected]> Date: Wed Jan 21 20:36:02 2009 +0100 More checks for signal contents commit 5603cb1942f076823274a426901cedef0a59937b Author: Marcel Holtmann <[email protected]> Date: Wed Jan 21 20:33:48 2009 +0100 Add support for unavailable state when daemon is not running commit 103eaa5e03eda759d970cb49fb8cc9fe25ee682f Author: Marcel Holtmann <[email protected]> Date: Wed Jan 21 20:06:47 2009 +0100 Add icon for unavailable indication commit deacd4b7d4ae537f71798cd3e794371545fbc768 Author: Marcel Holtmann <[email protected]> Date: Wed Jan 21 19:36:59 2009 +0100 Show preparation state when connection commit d17393649419980073145b92737cc9f845a26a9e Author: Marcel Holtmann <[email protected]> Date: Wed Jan 21 19:32:42 2009 +0100 Show configuration stage when connecting commit ec11681b71f8604a7a8e936ccef22b4f91c29893 Author: Marcel Holtmann <[email protected]> Date: Wed Jan 21 19:02:43 2009 +0100 Fix spelling mistake commit 03e012f71b940087e4c946f425c45d7366e3c543 Author: Marcel Holtmann <[email protected]> Date: Wed Jan 21 17:53:52 2009 +0100 Add menu item for disconnecting from network commit ae214504684e08baf1631c1106cd5e5ea33219e7 Author: Marcel Holtmann <[email protected]> Date: Wed Jan 21 17:53:39 2009 +0100 Add support for disconnecting all networks commit 62b22a066221264acf0c2945bbbb15307a41431f Author: Marcel Holtmann <[email protected]> Date: Wed Jan 21 17:31:16 2009 +0100 Add menu option to disconnect network commit 4c4b9eb21ca6fac9cb226e2fbfca1abeb8f73449 Author: Marcel Holtmann <[email protected]> Date: Wed Jan 21 17:26:35 2009 +0100 Add dialog to request passphrase commit c831b508a61bea19dc9a679e51cff9f09f98335f Author: Marcel Holtmann <[email protected]> Date: Wed Jan 21 17:26:24 2009 +0100 Add command for setting passphrase Diff in this email is a maximum of 400 lines. diff --git a/ChangeLog b/ChangeLog index 5d48025..0ef4648 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +ver 0.3: + Add dialog for setting passphrase of networks. + Add menu option to disconnect from a network. + Add status indication for preparation state. + Add status indication for connecting state. + Add extra checks for signal property handling. + Add special icon when daemon is not running. + Fix menu item entries when system is unavailable. + Fix status information update on disconnect. + Fix display of networks that are not in range. + ver 0.2: Add error checks for failed property calls. Add support for marking devices as connected. diff --git a/applet/main.c b/applet/main.c index 7b43c13..1de3afa 100644 --- a/applet/main.c +++ b/applet/main.c @@ -98,15 +98,83 @@ static void settings_callback(GtkWidget *item, gpointer user_data) g_printerr("Couldn't execute command: %s\n", command); } -static void show_error_dialog(const gchar *message) +static void toggled_callback(GtkWidget *button, gpointer user_data) { - GtkWidget *dialog; + GtkWidget *entry = user_data; + gboolean mode; - dialog = gtk_message_dialog_new_with_markup(NULL, GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - "%s", message); + mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); - gtk_dialog_run(GTK_DIALOG(dialog)); + 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), 16); + gtk_entry_set_width_chars(GTK_ENTRY(entry), 16); + 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); + + gtk_widget_show_all(dialog); + + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { + const gchar *passphrase; + + passphrase = gtk_entry_get_text(GTK_ENTRY(entry)); + + connman_client_set_passphrase(client, path, passphrase); + + status_prepare(); + connman_client_connect(client, path); + } gtk_widget_destroy(dialog); } @@ -122,6 +190,7 @@ static void activate_callback(GtkWidget *item, gpointer user_data) return; if (security == CONNMAN_SECURITY_NONE) { + status_prepare(); connman_client_connect(client, path); return; } @@ -129,11 +198,18 @@ static void activate_callback(GtkWidget *item, gpointer user_data) passphrase = connman_client_get_passphrase(client, path); if (passphrase != NULL) { g_free(passphrase); + + status_prepare(); connman_client_connect(client, path); return; } - show_error_dialog("Security settings for network are missing"); + passphrase_dialog(path, NULL); +} + +static void disconnect_callback(GtkWidget *item, gpointer user_data) +{ + connman_client_disconnect(client, NULL); } static GtkWidget *create_popupmenu(void) @@ -212,22 +288,25 @@ static void enumerate_networks(GtkMenu *menu, DBusGProxy *proxy; guint strength, security; gchar *name, *path; - gboolean connected; + 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); - item = append_menuitem(menu, name, security, strength); - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), + 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", + path = g_strdup(dbus_g_proxy_get_path(proxy)); + g_signal_connect(item, "activate", G_CALLBACK(activate_callback), path); + } g_free(name); @@ -275,6 +354,12 @@ static gboolean menu_callback(GtkMenu *menu) 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); + 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", @@ -338,6 +423,16 @@ static void connection_removed(GtkTreeModel *model, GtkTreePath *path, update_status(model); } +static void status_callback(const char *status, void *user_data) +{ + if (g_str_equal(status, "unavailable") == TRUE) + status_unavailable(); + else if (g_str_equal(status, "offline") == TRUE) + status_offline(); + else if (g_str_equal(status, "connecting") == TRUE) + status_config(); +} + int main(int argc, char *argv[]) { GtkTreeModel *model; @@ -365,6 +460,8 @@ int main(int argc, char *argv[]) update_status(model); + connman_client_set_callback(client, status_callback); + gtk_main(); g_object_unref(model); diff --git a/applet/status.c b/applet/status.c index 423252c..ef11bcc 100644 --- a/applet/status.c +++ b/applet/status.c @@ -27,6 +27,8 @@ #include "status.h" +static gboolean available = FALSE; + static GtkStatusIcon *statusicon = NULL; static GdkPixbuf *pixbuf_load(GtkIconTheme *icontheme, const gchar *name) @@ -98,6 +100,10 @@ static gboolean icon_animation_timeout(gpointer data) static void icon_animation_start(IconAnimation *animation, guint start, guint end) { + available = TRUE; + + gtk_status_icon_set_tooltip(statusicon, NULL); + animation->start = start; animation->end = (end == 0) ? animation->count - 1 : end; @@ -112,6 +118,10 @@ static void icon_animation_start(IconAnimation *animation, static void icon_animation_stop(IconAnimation *animation) { + available = TRUE; + + gtk_status_icon_set_tooltip(statusicon, NULL); + if (animation->id > 0) g_source_remove(animation->id); @@ -145,6 +155,9 @@ static void activate_callback(GObject *object, gpointer user_data) guint32 activate_time = gtk_get_current_event_time(); GtkWidget *menu; + if (available == FALSE) + return; + menu = gtk_menu_new(); if (callback == NULL || callback(GTK_MENU(menu)) == FALSE) { @@ -172,6 +185,7 @@ static void popup_callback(GObject *object, guint button, static GtkIconTheme *icontheme; static IconAnimation *animation; +static GdkPixbuf *pixbuf_notifier; static GdkPixbuf *pixbuf_none; static GdkPixbuf *pixbuf_wired; static GdkPixbuf *pixbuf_signal[5]; @@ -200,6 +214,7 @@ int status_init(StatusCallback activate, GtkWidget *popup) pixbuf_none = pixbuf_load(icontheme, "connman-type-none"); pixbuf_wired = pixbuf_load(icontheme, "connman-type-wired"); + pixbuf_notifier = pixbuf_load(icontheme, "connman-notifier-unavailable"); g_signal_connect(statusicon, "activate", G_CALLBACK(activate_callback), activate); @@ -221,18 +236,34 @@ void status_cleanup(void) g_object_unref(pixbuf_none); g_object_unref(pixbuf_wired); + g_object_unref(pixbuf_notifier); g_object_unref(icontheme); g_object_unref(statusicon); } +void status_unavailable(void) +{ + icon_animation_stop(animation); + + available = FALSE; + + gtk_status_icon_set_from_pixbuf(statusicon, pixbuf_notifier); + gtk_status_icon_set_tooltip(statusicon, + "Connection Manager daemon is not running"); + + gtk_status_icon_set_visible(statusicon, TRUE); +} + void status_hide(void) { gtk_status_icon_set_visible(statusicon, FALSE); icon_animation_stop(animation); + available = FALSE; + gtk_status_icon_set_from_pixbuf(statusicon, NULL); } @@ -263,8 +294,11 @@ static void set_ready(gint signal) { int index; + available = TRUE; + if (signal < 0) { gtk_status_icon_set_from_pixbuf(statusicon, pixbuf_wired); + gtk_status_icon_set_tooltip(statusicon, NULL); return; } @@ -274,6 +308,7 @@ static void set_ready(gint signal) index = 3; gtk_status_icon_set_from_pixbuf(statusicon, pixbuf_signal[index]); + gtk_status_icon_set_tooltip(statusicon, NULL); } struct timeout_data { diff --git a/applet/status.h b/applet/status.h index 6d4a6be..772a7b2 100644 --- a/applet/status.h +++ b/applet/status.h @@ -24,6 +24,7 @@ typedef gboolean (* StatusCallback) (GtkMenu *menu); int status_init(StatusCallback activate, GtkWidget *popup); void status_cleanup(void); +void status_unavailable(void); void status_hide(void); void status_offline(void); void status_prepare(void); diff --git a/common/connman-client.c b/common/connman-client.c index 96b5b2c..9d57ddd 100644 --- a/common/connman-client.c +++ b/common/connman-client.c @@ -57,10 +57,16 @@ static void name_owner_changed(DBusGProxy *dbus, const char *name, ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); GtkTreeIter iter; gboolean cont; + char *state, *oldstate; - if (g_str_equal(name, CONNMAN_SERVICE) == FALSE || *new != '\0') + if (g_str_equal(name, CONNMAN_SERVICE) == FALSE) return; + if (*new != '\0') { + state = "offline"; + goto done; + } + DBG("client %p name %s", client, name); cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), @@ -68,6 +74,17 @@ static void name_owner_changed(DBusGProxy *dbus, const char *name, while (cont == TRUE) cont = gtk_tree_store_remove(priv->store, &iter); + + state = "unavailable"; + +done: + oldstate = g_object_get_data(G_OBJECT(priv->store), "State"); + g_free(oldstate); + + g_object_set_data(G_OBJECT(priv->store), "State", g_strdup(state)); + + if (priv->callback != NULL) + priv->callback(state, NULL); } static DBusGConnection *connection = NULL; @@ -82,10 +99,11 @@ static void connman_client_init(ConnmanClient *client) 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_object_set_data(G_OBJECT(priv->store), "State", g_strdup("offline")); + g_object_set_data(G_OBJECT(priv->store), + "State", g_strdup("unavailable")); priv->dbus = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); @@ -436,6 +454,14 @@ void connman_client_connect(ConnmanClient *client, const gchar *network) g_object_unref(proxy); } +static void connman_client_disconnect_all(ConnmanClient *client) +{ _______________________________________________ Commits mailing list [email protected] https://lists.moblin.org/mailman/listinfo/commits
