diff options
author | Tobias Brunner <tobias@strongswan.org> | 2010-06-04 15:02:55 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2010-10-14 17:36:17 +0200 |
commit | 8df3749c6ab227c38145166ea0a257d0e370796a (patch) | |
tree | 66e60ddac9ed778a45e879bceeaee92580391b0a | |
parent | 59df6ff93c874d4d95cdde5c47e37e21ed8cbd85 (diff) | |
download | strongswan-8df3749c6ab227c38145166ea0a257d0e370796a.tar.bz2 strongswan-8df3749c6ab227c38145166ea0a257d0e370796a.tar.xz |
Dialog to initiate or terminate connections added.
-rw-r--r-- | src/frontends/maemo/src/Makefile.am | 7 | ||||
-rw-r--r-- | src/frontends/maemo/src/strongswan-status.c | 103 |
2 files changed, 108 insertions, 2 deletions
diff --git a/src/frontends/maemo/src/Makefile.am b/src/frontends/maemo/src/Makefile.am index 91c7be34e..952f85ccc 100644 --- a/src/frontends/maemo/src/Makefile.am +++ b/src/frontends/maemo/src/Makefile.am @@ -1,9 +1,12 @@ statuslib_LTLIBRARIES = libstrongswan-status.la libstrongswan_status_la_SOURCES = \ - strongswan-status.c strongswan-status.h + strongswan-status.c strongswan-status.h \ + strongswan-connection.c strongswan-connection.h \ + strongswan-connections.c strongswan-connections.h libstrongswan_status_la_LIBADD = $(HILDON_LIBS) $(DBUS_LIBS) $(OSSO_LIBS) -libstrongswan_status_la_CFLAGS = $(HILDON_CFLAGS) $(DBUS_CFLAGS) $(OSSO_CFLAGS) +libstrongswan_status_la_CFLAGS = -DUSE_DYNAMIC_TYPES \ + $(HILDON_CFLAGS) $(DBUS_CFLAGS) $(OSSO_CFLAGS) libstrongswan_status_la_LDFLAGS = -module -avoid-version pluginlib_LTLIBRARIES = libstrongswan-settings.la diff --git a/src/frontends/maemo/src/strongswan-status.c b/src/frontends/maemo/src/strongswan-status.c index 948660b9d..f1456269a 100644 --- a/src/frontends/maemo/src/strongswan-status.c +++ b/src/frontends/maemo/src/strongswan-status.c @@ -15,6 +15,9 @@ #include <hildon/hildon.h> +#include "strongswan-status.h" +#include "strongswan-connections.h" + #define STRONGSWAN_STATUS_GET_PRIVATE(object) \ (G_TYPE_INSTANCE_GET_PRIVATE ((object), \ STRONGSWAN_TYPE_STATUS, \ @@ -32,8 +35,15 @@ struct _StrongswanStatusPrivate GdkPixbuf *button_close; } icons; + GtkWidget *dialog; GtkWidget *button; GtkWidget *image; + GtkWidget *selector; + GtkWidget *box; + + StrongswanConnections *conns; + + gchar *current; }; HD_DEFINE_PLUGIN_MODULE_EXTENDED (StrongswanStatus, strongswan_status, \ @@ -42,9 +52,91 @@ HD_DEFINE_PLUGIN_MODULE_EXTENDED (StrongswanStatus, strongswan_status, \ strongswan_connections_register (G_TYPE_MODULE (plugin)); }, {}); static void +dialog_response (GtkDialog *dialog, gint response_id, StrongswanStatus *plugin) +{ + StrongswanStatusPrivate *priv = plugin->priv; + g_object_unref (priv->dialog); + priv->dialog = NULL; +} + +static void +connect_clicked (HildonButton *button, StrongswanStatus *plugin) +{ + StrongswanStatusPrivate *priv = plugin->priv; + gtk_dialog_response (GTK_DIALOG (priv->dialog), GTK_RESPONSE_OK); +} + +static void +disconnect_clicked (HildonButton *button, StrongswanStatus *plugin) +{ + StrongswanStatusPrivate *priv = plugin->priv; + gtk_dialog_response (GTK_DIALOG (priv->dialog), GTK_RESPONSE_OK); +} + +static void button_clicked (HildonButton *button, StrongswanStatus *plugin) { StrongswanStatusPrivate *priv = plugin->priv; + + priv->dialog = gtk_dialog_new (); + gtk_window_set_title (GTK_WINDOW (priv->dialog), "strongSwan VPN"); + g_signal_connect (priv->dialog, "response", + G_CALLBACK (dialog_response), plugin); + + GtkWidget *vbox = GTK_DIALOG (priv->dialog)->vbox; + + if (priv->current) + { + /* connected case */ + GtkWidget *hbox = gtk_hbox_new (FALSE, 0); + priv->box = hbox; + GtkWidget *button = hildon_button_new_with_text ( + HILDON_SIZE_FINGER_HEIGHT | + HILDON_SIZE_AUTO_WIDTH, + HILDON_BUTTON_ARRANGEMENT_HORIZONTAL, + "Disconnect", priv->current); + hildon_button_set_style (HILDON_BUTTON (button), + HILDON_BUTTON_STYLE_PICKER); + g_signal_connect (button, "clicked", G_CALLBACK (disconnect_clicked), + plugin); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + } + else + { + /* unconnected case */ + GtkWidget *hbox = gtk_hbox_new (FALSE, 0); + priv->box = hbox; + GtkWidget *button = hildon_picker_button_new ( + HILDON_SIZE_FINGER_HEIGHT | + HILDON_SIZE_AUTO_WIDTH, + HILDON_BUTTON_ARRANGEMENT_HORIZONTAL); + hildon_button_set_title (HILDON_BUTTON (button), "Connection:"); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); + + GtkWidget *selector = hildon_touch_selector_new (); + priv->selector = selector; + GtkTreeModel *model = strongswan_connections_get_model (priv->conns); + hildon_touch_selector_append_text_column ( + HILDON_TOUCH_SELECTOR (selector), + model, + TRUE); + hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button), + HILDON_TOUCH_SELECTOR (selector)); + g_object_unref (model); + + button = hildon_button_new_with_text ( + HILDON_SIZE_FINGER_HEIGHT | + HILDON_SIZE_AUTO_WIDTH, + HILDON_BUTTON_ARRANGEMENT_HORIZONTAL, + "Connect", NULL); + gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + g_signal_connect (button, "clicked", G_CALLBACK (connect_clicked), + plugin); + } + + gtk_widget_show_all (priv->dialog); } static void @@ -71,6 +163,8 @@ strongswan_status_init (StrongswanStatus *plugin) StrongswanStatusPrivate *priv = STRONGSWAN_STATUS_GET_PRIVATE (plugin); plugin->priv = priv; + priv->conns = strongswan_connections_new (); + load_icons(priv); hd_status_plugin_item_set_status_area_icon (HD_STATUS_PLUGIN_ITEM (plugin), @@ -100,6 +194,14 @@ static void strongswan_status_dispose (GObject *object) { StrongswanStatusPrivate *priv = STRONGSWAN_STATUS (object)->priv; + if (priv->conns) + { + priv->conns = (g_object_unref (priv->conns), NULL); + } + if (priv->dialog) + { + priv->dialog = (g_object_unref (priv->dialog), NULL); + } if (priv->icons.status_open) { g_object_unref (priv->icons.status_open); @@ -127,6 +229,7 @@ static void strongswan_status_finalize (GObject *object) { StrongswanStatusPrivate *priv = STRONGSWAN_STATUS (object)->priv; + priv->current = (g_free (priv->current), NULL); G_OBJECT_CLASS (strongswan_status_parent_class)->finalize (object); } |