diff options
author | Tobias Brunner <tobias@strongswan.org> | 2016-09-06 16:12:51 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2016-09-15 18:33:52 +0200 |
commit | 5f564b94a0ed24562ca5eb150e2b60bc3a2d0000 (patch) | |
tree | 948f719ca7a8488d8706d3155dc327d61aee1e23 /src/frontends | |
parent | 318a48a5899bc9d9440995357c3389c6b99f5ba6 (diff) | |
download | strongswan-5f564b94a0ed24562ca5eb150e2b60bc3a2d0000.tar.bz2 strongswan-5f564b94a0ed24562ca5eb150e2b60bc3a2d0000.tar.xz |
maemo: Remove obsolete status/settings applet
Diffstat (limited to 'src/frontends')
23 files changed, 0 insertions, 1850 deletions
diff --git a/src/frontends/maemo/.gitignore b/src/frontends/maemo/.gitignore deleted file mode 100644 index 5568822e5..000000000 --- a/src/frontends/maemo/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -build-arch-stamp -build-indep-stamp diff --git a/src/frontends/maemo/AUTHORS b/src/frontends/maemo/AUTHORS deleted file mode 100644 index e69de29bb..000000000 --- a/src/frontends/maemo/AUTHORS +++ /dev/null diff --git a/src/frontends/maemo/ChangeLog b/src/frontends/maemo/ChangeLog deleted file mode 100644 index e69de29bb..000000000 --- a/src/frontends/maemo/ChangeLog +++ /dev/null diff --git a/src/frontends/maemo/Makefile.am b/src/frontends/maemo/Makefile.am deleted file mode 100644 index f3e344fa4..000000000 --- a/src/frontends/maemo/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ - -SUBDIRS = src data - diff --git a/src/frontends/maemo/NEWS b/src/frontends/maemo/NEWS deleted file mode 100644 index ffacf7098..000000000 --- a/src/frontends/maemo/NEWS +++ /dev/null @@ -1,4 +0,0 @@ -strongswan-applet-1.0.0 ------------------------ - -- Initial release diff --git a/src/frontends/maemo/README b/src/frontends/maemo/README deleted file mode 100644 index e69de29bb..000000000 --- a/src/frontends/maemo/README +++ /dev/null diff --git a/src/frontends/maemo/autogen.sh b/src/frontends/maemo/autogen.sh deleted file mode 100755 index 6039708df..000000000 --- a/src/frontends/maemo/autogen.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -libtoolize --force && -aclocal && -automake -a && -autoconf diff --git a/src/frontends/maemo/configure.ac b/src/frontends/maemo/configure.ac deleted file mode 100644 index aae322fa2..000000000 --- a/src/frontends/maemo/configure.ac +++ /dev/null @@ -1,54 +0,0 @@ -AC_INIT(strongswan-applet, 1.0.1) -AM_INIT_AUTOMAKE - -# Programs -AC_PROG_CC -AC_PROG_INSTALL -AC_PROG_LIBTOOL - -# Headers -AC_HEADER_STDC - -# Library dependencies -PKG_CHECK_MODULES(HILDON, hildon-1 hildon-fm-2 hildon-control-panel libhildondesktop-1) -AC_SUBST(HILDON_CFLAGS) -AC_SUBST(HILDON_LIBS) - -PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.60) -AC_SUBST(DBUS_CFLAGS) -AC_SUBST(DBUS_LIBS) - -PKG_CHECK_MODULES(OSSO, osso-af-settings >= 0.8.5 libosso >= 0.9.17 gnome-vfs-2.0 >= 2.8.4.11 gnome-vfs-module-2.0 >= 2.8.4.11) -AC_SUBST(OSSO_CFLAGS) -AC_SUBST(OSSO_LIBS) - -# Application icon install directories -icon_18x18dir=$datadir/icons/hicolor/18x18/hildon -icon_24x24dir=$datadir/icons/hicolor/24x24/hildon -icon_32x32dir=$datadir/icons/hicolor/32x32/hildon -icon_48x48dir=$datadir/icons/hicolor/48x48/hildon -icon_scalabledir=$datadir/icons/hicolor/scalable/hildon - -# Hildon control panel plugin install directories -pluginlibdir=`$PKG_CONFIG hildon-control-panel --variable=pluginlibdir` -plugindesktopentrydir=`$PKG_CONFIG hildon-control-panel --variable=plugindesktopentrydir` - -# Hildon status widget install directories -statuslibdir=`$PKG_CONFIG libhildondesktop-1 --variable=hildondesktoplibdir` -statusdesktopentrydir=`$PKG_CONFIG libhildondesktop-1 --variable=hildonstatusmenudesktopentrydir` - -AC_SUBST(icon_18x18dir) -AC_SUBST(icon_24x24dir) -AC_SUBST(icon_32x32dir) -AC_SUBST(icon_48x48dir) -AC_SUBST(icon_scalabledir) -AC_SUBST(pluginlibdir) -AC_SUBST(plugindesktopentrydir) -AC_SUBST(statuslibdir) -AC_SUBST(statusdesktopentrydir) - -AC_OUTPUT( - Makefile \ - src/Makefile \ - data/Makefile -) diff --git a/src/frontends/maemo/data/Makefile.am b/src/frontends/maemo/data/Makefile.am deleted file mode 100644 index 69af067da..000000000 --- a/src/frontends/maemo/data/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -plugindesktopentry_DATA = strongswan-settings.desktop - -statusdesktopentry_DATA = strongswan-status.desktop - -icon_18x18_DATA = \ - icons/18x18/strongswan_lock_open.png \ - icons/18x18/strongswan_lock_close.png -icon_48x48_DATA = \ - icons/48x48/strongswan_lock_open.png \ - icons/48x48/strongswan_lock_close.png - -EXTRA_DIST = \ - $(plugindesktopentry_DATA) $(statusdesktopentry_DATA) \ - $(icon_18x18_DATA) $(icon_48x48_DATA) - diff --git a/src/frontends/maemo/data/icons/18x18/strongswan_lock_close.png b/src/frontends/maemo/data/icons/18x18/strongswan_lock_close.png Binary files differdeleted file mode 100644 index b193d0dc8..000000000 --- a/src/frontends/maemo/data/icons/18x18/strongswan_lock_close.png +++ /dev/null diff --git a/src/frontends/maemo/data/icons/18x18/strongswan_lock_open.png b/src/frontends/maemo/data/icons/18x18/strongswan_lock_open.png Binary files differdeleted file mode 100644 index 16aabd2f9..000000000 --- a/src/frontends/maemo/data/icons/18x18/strongswan_lock_open.png +++ /dev/null diff --git a/src/frontends/maemo/data/icons/48x48/strongswan_lock_close.png b/src/frontends/maemo/data/icons/48x48/strongswan_lock_close.png Binary files differdeleted file mode 100644 index 9fdda0aa7..000000000 --- a/src/frontends/maemo/data/icons/48x48/strongswan_lock_close.png +++ /dev/null diff --git a/src/frontends/maemo/data/icons/48x48/strongswan_lock_open.png b/src/frontends/maemo/data/icons/48x48/strongswan_lock_open.png Binary files differdeleted file mode 100644 index cba331fff..000000000 --- a/src/frontends/maemo/data/icons/48x48/strongswan_lock_open.png +++ /dev/null diff --git a/src/frontends/maemo/data/strongswan-settings.desktop b/src/frontends/maemo/data/strongswan-settings.desktop deleted file mode 100644 index f5887f8ea..000000000 --- a/src/frontends/maemo/data/strongswan-settings.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Name=strongSwan VPN -Comment=A control panel applet to configure strongSwan VPN -Type=HildonControlPanelPlugin -Icon=strongswan_lock_close -Categories=connectivity -X-control-panel-plugin=libstrongswan-settings.so diff --git a/src/frontends/maemo/data/strongswan-status.desktop b/src/frontends/maemo/data/strongswan-status.desktop deleted file mode 100644 index ef2f5c44f..000000000 --- a/src/frontends/maemo/data/strongswan-status.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Name=strongSwan Status -Comment=A status menu widget to control strongSwan -Type=default -Icon=strongswan_lock_close -Category=permanent -X-Path=libstrongswan-status.so diff --git a/src/frontends/maemo/src/Makefile.am b/src/frontends/maemo/src/Makefile.am deleted file mode 100644 index 952f85ccc..000000000 --- a/src/frontends/maemo/src/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ -statuslib_LTLIBRARIES = libstrongswan-status.la -libstrongswan_status_la_SOURCES = \ - 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 = -DUSE_DYNAMIC_TYPES \ - $(HILDON_CFLAGS) $(DBUS_CFLAGS) $(OSSO_CFLAGS) -libstrongswan_status_la_LDFLAGS = -module -avoid-version - -pluginlib_LTLIBRARIES = libstrongswan-settings.la -libstrongswan_settings_la_SOURCES = \ - strongswan-settings.c \ - strongswan-connection.c strongswan-connection.h \ - strongswan-connections.c strongswan-connections.h - -libstrongswan_settings_la_LIBADD = $(HILDON_LIBS) -libstrongswan_settings_la_CFLAGS = $(HILDON_CFLAGS) -libstrongswan_settings_la_LDFLAGS = -module -avoid-version - diff --git a/src/frontends/maemo/src/strongswan-connection.c b/src/frontends/maemo/src/strongswan-connection.c deleted file mode 100644 index c7d0db355..000000000 --- a/src/frontends/maemo/src/strongswan-connection.c +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (C) 2010 Tobias Brunner - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#include <string.h> - -#include "strongswan-connection.h" - -#define STRONGSWAN_CONNECTION_GET_PRIVATE(object) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((object), \ - STRONGSWAN_TYPE_CONNECTION, \ - StrongswanConnectionPrivate)) - -struct _StrongswanConnectionPrivate -{ - gchar *orig_name; - gchar *name; - gchar *host; - gchar *cert; - gchar *user; -}; - -enum -{ - PROP_0, - PROP_NAME, - PROP_HOST, - PROP_CERT, - PROP_USER, -}; - -#ifndef USE_DYNAMIC_TYPES -G_DEFINE_TYPE (StrongswanConnection, strongswan_connection, G_TYPE_OBJECT); -#else -G_DEFINE_DYNAMIC_TYPE (StrongswanConnection, strongswan_connection, G_TYPE_OBJECT); -void strongswan_connection_register (GTypeModule *type_module) -{ - strongswan_connection_register_type (type_module); -} -#endif - -static void -strongswan_connection_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - StrongswanConnectionPrivate *priv = STRONGSWAN_CONNECTION (object)->priv; - switch (prop_id) - { - case PROP_NAME: - g_value_set_string (value, priv->name); - break; - case PROP_HOST: - g_value_set_string (value, priv->host); - break; - case PROP_CERT: - g_value_set_string (value, priv->cert); - break; - case PROP_USER: - g_value_set_string (value, priv->user); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -strongswan_connection_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - StrongswanConnectionPrivate *priv = STRONGSWAN_CONNECTION (object)->priv; - switch (prop_id) - { - case PROP_NAME: - g_free (priv->name); - priv->name = g_value_dup_string (value); - case PROP_HOST: - g_free (priv->host); - priv->host = g_value_dup_string (value); - break; - case PROP_CERT: - g_free (priv->cert); - priv->cert = g_value_dup_string (value); - break; - case PROP_USER: - g_free (priv->user); - priv->user = g_value_dup_string (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -strongswan_connection_init (StrongswanConnection *connection) -{ - connection->priv = STRONGSWAN_CONNECTION_GET_PRIVATE (connection); -} - -static void -strongswan_connection_dispose (GObject *object) -{ - G_OBJECT_CLASS (strongswan_connection_parent_class)->dispose (object); -} - -static void -strongswan_connection_finalize (GObject *object) -{ - StrongswanConnectionPrivate *priv = STRONGSWAN_CONNECTION (object)->priv; - g_free (priv->orig_name); - g_free (priv->name); - g_free (priv->host); - g_free (priv->cert); - g_free (priv->user); - G_OBJECT_CLASS (strongswan_connection_parent_class)->finalize (object); -} - -static void -strongswan_connection_class_init (StrongswanConnectionClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->get_property = strongswan_connection_get_property; - object_class->set_property = strongswan_connection_set_property; - object_class->dispose = strongswan_connection_dispose; - object_class->finalize = strongswan_connection_finalize; - - g_object_class_install_property (object_class, PROP_NAME, - g_param_spec_string ("name", "Connection name", - "The unique name of a connection", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property (object_class, PROP_HOST, - g_param_spec_string ("host", "Hostname or IP address", - "The hostname or IP address of the Gateway", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property (object_class, PROP_CERT, - g_param_spec_string ("cert", "Gateway or CA certificate", - "The certificate of the gateway or the CA", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property (object_class, PROP_USER, - g_param_spec_string ("user", "Username", - "The username for EAP authentication", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - g_type_class_add_private (klass, sizeof (StrongswanConnectionPrivate)); -} - -#ifdef USE_DYNAMIC_TYPES -static void -strongswan_connection_class_finalize (StrongswanConnectionClass *klass) -{ -} -#endif - -static inline gchar * -get_string_from_key_file (GKeyFile *key_file, - const gchar *name, - const gchar *key) -{ - GError *error = NULL; - gchar *value; - value = g_key_file_get_string (key_file, name, key, &error); - if (error) - { - g_warning ("Failed to read %s/%s from key file: %s", - name, key, error->message); - g_error_free (error); - } - return value; -} - -static void -strongswan_connection_update_from_key_file (GKeyFile *key_file, - StrongswanConnection *connection) -{ - StrongswanConnectionPrivate *priv = connection->priv; - gchar *name = priv->name; - - priv->orig_name = g_strdup (name); - priv->host = get_string_from_key_file (key_file, name, "host"); - priv->cert = get_string_from_key_file (key_file, name, "cert"); - priv->user = get_string_from_key_file (key_file, name, "user"); -} - -StrongswanConnection * -strongswan_connection_new (const gchar *name) -{ - StrongswanConnection *conn; - conn = g_object_new (STRONGSWAN_TYPE_CONNECTION, - "name", name, - NULL); - g_return_val_if_fail (conn->priv != NULL, NULL); - return conn; -} - -StrongswanConnection * -strongswan_connection_new_from_key_file (GKeyFile *key_file, - const gchar *name) -{ - StrongswanConnection *conn = strongswan_connection_new (name); - g_return_val_if_fail (conn != NULL, NULL); - strongswan_connection_update_from_key_file (key_file, conn); - return conn; -} - -void -strongswan_connection_save_to_key_file (GKeyFile *key_file, - StrongswanConnection *connection) -{ - StrongswanConnectionPrivate *priv = connection->priv; - gchar *name = priv->name; - - if (priv->orig_name && strcmp (name, priv->orig_name)) - { - g_key_file_remove_group (key_file, priv->orig_name, NULL); - g_free (priv->orig_name); - priv->orig_name = g_strdup (name); - } - - if (priv->host) - { - g_key_file_set_string (key_file, name, "host", priv->host); - } - if (priv->cert) - { - g_key_file_set_string (key_file, name, "cert", priv->cert); - } - else - { - g_key_file_remove_key (key_file, name, "cert", NULL); - } - if (priv->user) - { - g_key_file_set_string (key_file, name, "user", priv->user); - } -} - diff --git a/src/frontends/maemo/src/strongswan-connection.h b/src/frontends/maemo/src/strongswan-connection.h deleted file mode 100644 index 2e4fd45ec..000000000 --- a/src/frontends/maemo/src/strongswan-connection.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2010 Tobias Brunner - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef __STRONGSWAN_CONNECTION_H__ -#define __STRONGSWAN_CONNECTION_H__ - -#include <glib.h> -#include <glib-object.h> - -G_BEGIN_DECLS - -#define STRONGSWAN_TYPE_CONNECTION (strongswan_connection_get_type ()) -#define STRONGSWAN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), STRONGSWAN_TYPE_CONNECTION, StrongswanConnection)) -#define STRONGSWAN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), STRONGSWAN_TYPE_CONNECTION, StrongswanConnectionClass)) -#define STRONGSWAN_IS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), STRONGSWAN_TYPE_CONNECTION)) -#define STRONGSWAN_IS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), STRONGSWAN_TYPE_CONNECTION)) -#define STRONGSWAN_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), STRONGSWAN_TYPE_CONNECTION, StrongswanConnectionClass)) - -typedef struct _StrongswanConnection StrongswanConnection; -typedef struct _StrongswanConnectionClass StrongswanConnectionClass; -typedef struct _StrongswanConnectionPrivate StrongswanConnectionPrivate; - -struct _StrongswanConnection -{ - GObject gobject; - - StrongswanConnectionPrivate *priv; -}; - -struct _StrongswanConnectionClass -{ - GObjectClass parent_class; -}; - -GType strongswan_connection_get_type (void); - -StrongswanConnection *strongswan_connection_new (const gchar *name); - -StrongswanConnection *strongswan_connection_new_from_key_file(GKeyFile *key_file, const gchar *name); -void strongswan_connection_save_to_key_file (GKeyFile *key_file, StrongswanConnection *connection); - -#ifdef USE_DYNAMIC_TYPES -void strongswan_connection_register (GTypeModule *type_module); -#endif - -G_END_DECLS - -#endif /* __STRONGSWAN_CONNECTION_H__ */ diff --git a/src/frontends/maemo/src/strongswan-connections.c b/src/frontends/maemo/src/strongswan-connections.c deleted file mode 100644 index f5ba55c84..000000000 --- a/src/frontends/maemo/src/strongswan-connections.c +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (C) 2010 Tobias Brunner - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#include <glib.h> -#include <libgnomevfs/gnome-vfs.h> - -#include "strongswan-connections.h" - -/* connections are stored in ~/.config/strongswan/connections */ -#define CONFIG_DIR_NAME "strongswan" -#define CONFIG_FILE_NAME "connections" - -#define STRONGSWAN_CONNECTIONS_GET_PRIVATE(object) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((object), STRONGSWAN_TYPE_CONNECTIONS, StrongswanConnectionsPrivate)) - -struct _StrongswanConnectionsPrivate -{ - GKeyFile *key_file; - gchar *path; - GnomeVFSMonitorHandle *monitor; - GHashTable *connections; - GtkTreeModel *model; -}; - -#ifndef USE_DYNAMIC_TYPES -G_DEFINE_TYPE (StrongswanConnections, strongswan_connections, G_TYPE_OBJECT); -#else -G_DEFINE_DYNAMIC_TYPE (StrongswanConnections, strongswan_connections, G_TYPE_OBJECT); -void strongswan_connections_register (GTypeModule *type_module) -{ - strongswan_connections_register_type (type_module); -} -#endif - -static void -strongswan_connections_load_connections (StrongswanConnections *connections) -{ - StrongswanConnectionsPrivate *priv = connections->priv; - GHashTableIter iter; - gpointer key, value; - gchar **groups; - guint i; - - g_hash_table_remove_all (priv->connections); - groups = g_key_file_get_groups (priv->key_file, NULL); - for (i = 0; groups[i]; i++) - { - StrongswanConnection *conn; - conn = strongswan_connection_new_from_key_file(priv->key_file, - groups[i]); - if (conn != NULL) - { - g_hash_table_insert (priv->connections, - g_strdup(groups[i]), - conn); - } - } - g_strfreev (groups); - - gtk_list_store_clear (GTK_LIST_STORE (priv->model)); - g_hash_table_iter_init (&iter, priv->connections); - while (g_hash_table_iter_next (&iter, &key, &value)) - { - gtk_list_store_insert_with_values (GTK_LIST_STORE (priv->model), - NULL, - -1, - 0, key, - -1); - } -} - -static void -strongswan_connections_load_config (StrongswanConnections *connections) -{ - StrongswanConnectionsPrivate *priv = connections->priv; - GError *error = NULL; - - if (priv->key_file) - { - g_key_file_free (priv->key_file); - } - - priv->key_file = g_key_file_new (); - if (!g_key_file_load_from_file (priv->key_file, - priv->path, - G_KEY_FILE_KEEP_COMMENTS, - &error)) - { - if (g_error_matches (error, - G_KEY_FILE_ERROR, - G_KEY_FILE_ERROR_PARSE)) - { - g_debug ("Failed to parse config file '%s', treated as empty: %s", - priv->path, error->message); - g_error_free (error); - } - else - { - g_debug ("Could not read config file '%s': %s", - priv->path, error->message); - g_error_free (error); - } - } - - strongswan_connections_load_connections (connections); -} - -static void -strongswan_connections_file_changed (GnomeVFSMonitorHandle *handle, - const gchar *monitor_uri, - const gchar *info_uri, - GnomeVFSMonitorEventType event_type, - StrongswanConnections *connections) -{ - strongswan_connections_load_config (connections); -} - - -static void -strongswan_connections_init (StrongswanConnections *connections) -{ - StrongswanConnectionsPrivate *priv; - connections->priv = STRONGSWAN_CONNECTIONS_GET_PRIVATE (connections); - priv = connections->priv; - - priv->path = g_build_filename (g_get_user_config_dir (), - CONFIG_DIR_NAME, - CONFIG_FILE_NAME, - NULL); - /* ensure that the directory exists */ - gchar *dir = g_path_get_dirname (priv->path); - g_mkdir_with_parents (dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); - g_free (dir); - - priv->connections = g_hash_table_new_full (g_str_hash, - g_str_equal, - g_free, - g_object_unref); - - priv->model = GTK_TREE_MODEL (gtk_list_store_new (2, - G_TYPE_STRING, - G_TYPE_STRING)); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (priv->model), - 0, - GTK_SORT_ASCENDING); -} - -static void -strongswan_connections_constructed (GObject *object) -{ - StrongswanConnectionsPrivate *priv; - GnomeVFSResult result; - - if (G_OBJECT_CLASS (strongswan_connections_parent_class)->constructed) - { - G_OBJECT_CLASS (strongswan_connections_parent_class)->constructed (object); - } - - g_return_if_fail (STRONGSWAN_IS_CONNECTIONS (object)); - priv = STRONGSWAN_CONNECTIONS (object)->priv; - - result = gnome_vfs_monitor_add (&priv->monitor, - priv->path, - GNOME_VFS_MONITOR_FILE, - (GnomeVFSMonitorCallback) strongswan_connections_file_changed, - object); - if (result != GNOME_VFS_OK) - { - g_warning ("Could not monitor '%s': %s", - priv->path, - gnome_vfs_result_to_string (result)); - } - - strongswan_connections_load_config (STRONGSWAN_CONNECTIONS (object)); -} - -static void -strongswan_connections_dispose (GObject *object) -{ - StrongswanConnectionsPrivate *priv; - - g_return_if_fail (STRONGSWAN_IS_CONNECTIONS (object)); - priv = STRONGSWAN_CONNECTIONS (object)->priv; - - if (priv->model) - { - priv->model = (g_object_unref (priv->model), NULL); - } - - G_OBJECT_CLASS (strongswan_connections_parent_class)->dispose (object); -} - -static void -strongswan_connections_finalize (GObject *object) -{ - StrongswanConnectionsPrivate *priv; - - g_return_if_fail (STRONGSWAN_IS_CONNECTIONS (object)); - priv = STRONGSWAN_CONNECTIONS (object)->priv; - - priv->path = (g_free (priv->path), NULL); - priv->monitor = (gnome_vfs_monitor_cancel (priv->monitor), NULL); - priv->key_file = (g_key_file_free (priv->key_file), NULL); - priv->connections = (g_hash_table_destroy (priv->connections), NULL); - - G_OBJECT_CLASS (strongswan_connections_parent_class)->finalize (object); -} - -static void -strongswan_connections_class_init (StrongswanConnectionsClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->constructed = strongswan_connections_constructed; - object_class->dispose = strongswan_connections_dispose; - object_class->finalize = strongswan_connections_finalize; - - g_type_class_add_private (klass, sizeof (StrongswanConnectionsPrivate)); -} - -#ifdef USE_DYNAMIC_TYPES -static void -strongswan_connections_class_finalize (StrongswanConnectionsClass *klass) -{ -} -#endif - -GtkTreeModel * -strongswan_connections_get_model (StrongswanConnections *self) -{ - StrongswanConnectionsPrivate *priv = self->priv; - return g_object_ref (priv->model); -} - -void -strongswan_connections_setup_column_renderers (StrongswanConnections *self, - GtkCellLayout *layout) -{ - GtkCellRenderer *renderer; - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (layout, - renderer, - TRUE); - gtk_cell_layout_add_attribute (layout, - renderer, - "text", 0); -} - -StrongswanConnections * -strongswan_connections_new (void) -{ - StrongswanConnections *connections; - connections = g_object_new (STRONGSWAN_TYPE_CONNECTIONS, - NULL); - return connections; -} - -StrongswanConnection * -strongswan_connections_get_connection (StrongswanConnections *self, - const gchar *name) -{ - StrongswanConnectionsPrivate *priv = self->priv; - g_return_val_if_fail (name != NULL, NULL); - return g_hash_table_lookup (priv->connections, name); -} - -static void -strongswan_connections_save_connections (StrongswanConnections *self) -{ - StrongswanConnectionsPrivate *priv = self->priv; - gchar *data; - gsize size; - GError *error = NULL; - - data = g_key_file_to_data (priv->key_file, &size, NULL); - if (!g_file_set_contents (priv->path, data, size, &error)) - { - g_warning ("Failed to save connections to '%s': %s", - priv->path, error->message); - g_error_free (error); - } - g_free (data); -} - -void -strongswan_connections_save_connection (StrongswanConnections *self, - StrongswanConnection *conn) -{ - StrongswanConnectionsPrivate *priv = self->priv; - - strongswan_connection_save_to_key_file (priv->key_file, conn); - - strongswan_connections_save_connections (self); -} - -void -strongswan_connections_remove_connection (StrongswanConnections *self, - const gchar *name) -{ - StrongswanConnectionsPrivate *priv = self->priv; - - g_key_file_remove_group (priv->key_file, name, NULL); - - strongswan_connections_save_connections (self); -} - diff --git a/src/frontends/maemo/src/strongswan-connections.h b/src/frontends/maemo/src/strongswan-connections.h deleted file mode 100644 index f7a42acad..000000000 --- a/src/frontends/maemo/src/strongswan-connections.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2010 Tobias Brunner - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef __STRONGSWAN_CONNECTIONS_H__ -#define __STRONGSWAN_CONNECTIONS_H__ - -#include <gtk/gtk.h> - -#include "strongswan-connection.h" - -G_BEGIN_DECLS - -#define STRONGSWAN_TYPE_CONNECTIONS (strongswan_connections_get_type ()) -#define STRONGSWAN_CONNECTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), STRONGSWAN_TYPE_CONNECTIONS, StrongswanConnections)) -#define STRONGSWAN_CONNECTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), STRONGSWAN_TYPE_CONNECTIONS, StrongswanConnectionsClass)) -#define STRONGSWAN_IS_CONNECTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), STRONGSWAN_TYPE_CONNECTIONS)) -#define STRONGSWAN_IS_CONNECTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), STRONGSWAN_TYPE_CONNECTIONS)) -#define STRONGSWAN_CONNECTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), STRONGSWAN_TYPE_CONNECTIONS, StrongswanConnectionsClass)) - -typedef struct _StrongswanConnections StrongswanConnections; -typedef struct _StrongswanConnectionsClass StrongswanConnectionsClass; -typedef struct _StrongswanConnectionsPrivate StrongswanConnectionsPrivate; - -struct _StrongswanConnections -{ - GObject gobject; - - StrongswanConnectionsPrivate *priv; -}; - -struct _StrongswanConnectionsClass -{ - GObjectClass parent_class; -}; - -GType strongswan_connections_get_type (void); - -StrongswanConnections *strongswan_connections_new (void); - -GtkTreeModel *strongswan_connections_get_model (StrongswanConnections *connections); -void strongswan_connections_setup_column_renderers (StrongswanConnections *connections, GtkCellLayout *layout); - -StrongswanConnection *strongswan_connections_get_connection (StrongswanConnections *self, const gchar *name); -void strongswan_connections_save_connection (StrongswanConnections *self, StrongswanConnection *conn); -void strongswan_connections_remove_connection (StrongswanConnections *self, const gchar *name); - -#ifdef USE_DYNAMIC_TYPES -void strongswan_connections_register (GTypeModule *type_module); -#endif - -G_END_DECLS - -#endif /* __STRONGSWAN_CONNECTIONS_H__ */ diff --git a/src/frontends/maemo/src/strongswan-settings.c b/src/frontends/maemo/src/strongswan-settings.c deleted file mode 100644 index 9773590f6..000000000 --- a/src/frontends/maemo/src/strongswan-settings.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Copyright (C) 2010 Tobias Brunner - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#include <hildon-cp-plugin/hildon-cp-plugin-interface.h> -#include <gtk/gtk.h> -#include <hildon/hildon.h> -#include <hildon/hildon-file-chooser-dialog.h> - -#include <string.h> - -#include "strongswan-connections.h" - -enum { - RESPONSE_NEW = 1, - RESPONSE_EDIT, - RESPONSE_DELETE -}; - -struct { - GtkWidget *dialog; - GtkWidget *list; - StrongswanConnections *conns; -} ListDialog = { 0, }; - -/** - * Callback if no certificate should be selected - */ -void no_certificate(HildonButton *button, gpointer user_data) -{ - gtk_dialog_response (GTK_DIALOG (user_data), GTK_RESPONSE_REJECT); -} - -/** - * Callback to select a certificate - */ -void select_cert(HildonButton *button, gpointer user_data) -{ - GtkWidget *selector = hildon_file_chooser_dialog_new (GTK_WINDOW (user_data), GTK_FILE_CHOOSER_ACTION_OPEN); - GtkWidget *nocert = hildon_button_new (HILDON_SIZE_FINGER_HEIGHT | - HILDON_SIZE_AUTO_WIDTH, - HILDON_BUTTON_ARRANGEMENT_VERTICAL); - hildon_button_set_text (HILDON_BUTTON (nocert), - "No certificate", - "Use system-wide CA certificates"); - hildon_button_set_alignment (HILDON_BUTTON (nocert), 0, 0.5, 1, 1); - g_signal_connect (nocert, "clicked", G_CALLBACK (no_certificate), selector); - hildon_file_chooser_dialog_add_extra (HILDON_FILE_CHOOSER_DIALOG (selector), - nocert); - gtk_widget_show_all (selector); - - switch (gtk_dialog_run (GTK_DIALOG (selector))) - { - case GTK_RESPONSE_OK: - { - gchar *file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (selector)); - hildon_button_set_value (button, file); - g_free(file); - break; - } - case GTK_RESPONSE_REJECT: - { - hildon_button_set_value (button, "None"); - break; - } - default: - break; - } - gtk_widget_destroy (selector); -} - -/** - * Shows a dialog to edit the given connection (or create a new one, - * if conn is NULL) - */ -static void -edit_connection (gpointer *parent, StrongswanConnection *conn) -{ - GtkWidget *dialog; - dialog = gtk_dialog_new_with_buttons ( - conn ? "Edit Connection" : "New Connection", - GTK_WINDOW (parent), - GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, - GTK_RESPONSE_OK, - NULL); - GtkWidget *vbox = GTK_DIALOG (dialog)->vbox; - GtkSizeGroup *group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - - GtkWidget *name = hildon_entry_new (HILDON_SIZE_AUTO); - hildon_gtk_entry_set_placeholder_text (GTK_ENTRY (name), "Connection Name"); - hildon_gtk_entry_set_input_mode (GTK_ENTRY (name), - HILDON_GTK_INPUT_MODE_AUTOCAP | - HILDON_GTK_INPUT_MODE_ALPHA | - HILDON_GTK_INPUT_MODE_NUMERIC); - GtkWidget *ncap = hildon_caption_new (group, - "Name", - name, - NULL, - HILDON_CAPTION_OPTIONAL); - gtk_box_pack_start (GTK_BOX (vbox), ncap, TRUE, TRUE, 0); - - GtkWidget *host = hildon_entry_new (HILDON_SIZE_AUTO); - hildon_gtk_entry_set_placeholder_text (GTK_ENTRY (host), "Hostname / IP"); - hildon_gtk_entry_set_input_mode (GTK_ENTRY (host), - HILDON_GTK_INPUT_MODE_FULL); - GtkWidget *hcap = hildon_caption_new (group, - "Host", - host, - NULL, - HILDON_CAPTION_OPTIONAL); - gtk_box_pack_start (GTK_BOX (vbox), hcap, TRUE, TRUE, 0); - - GtkWidget *cert = hildon_button_new (HILDON_SIZE_FINGER_HEIGHT | - HILDON_SIZE_AUTO_WIDTH, - HILDON_BUTTON_ARRANGEMENT_VERTICAL); - hildon_button_set_text (HILDON_BUTTON (cert), - "Host or CA Certificate", - "None"); - hildon_button_set_alignment (HILDON_BUTTON (cert), 0, 0.5, 1, 1); - g_signal_connect (cert, "clicked", G_CALLBACK (select_cert), dialog); - GtkWidget *ccap = hildon_caption_new (group, - "Certificate", - cert, - NULL, - HILDON_CAPTION_OPTIONAL); - gtk_box_pack_start (GTK_BOX (vbox), ccap, TRUE, TRUE, 0); - - GtkWidget *user = hildon_entry_new (HILDON_SIZE_AUTO); - hildon_gtk_entry_set_placeholder_text (GTK_ENTRY (user), "Username"); - hildon_gtk_entry_set_input_mode (GTK_ENTRY (user), - HILDON_GTK_INPUT_MODE_FULL); - GtkWidget *ucap = hildon_caption_new (group, - "Username", - user, - NULL, - HILDON_CAPTION_OPTIONAL); - gtk_box_pack_start (GTK_BOX (vbox), ucap, TRUE, TRUE, 0); - - if (conn) - { - gchar *c_name, *c_host, *c_cert, *c_user; - g_object_get (conn, - "name", &c_name, - "host", &c_host, - "cert", &c_cert, - "user", &c_user, - NULL); - gtk_entry_set_text (GTK_ENTRY (name), c_name); - gtk_entry_set_text (GTK_ENTRY (host), c_host); - hildon_button_set_value (HILDON_BUTTON (cert), - c_cert ? c_cert : "None"); - gtk_entry_set_text (GTK_ENTRY (user), c_user); - g_free (c_name); - g_free (c_host); - g_free (c_cert); - g_free (c_user); - } - - gtk_widget_show_all (dialog); - - gint retval = gtk_dialog_run (GTK_DIALOG (dialog)); - if (retval == GTK_RESPONSE_OK) - { - const gchar *c_name, *c_cert; - c_name = gtk_entry_get_text (GTK_ENTRY (name)); - if (!conn) - { - conn = strongswan_connection_new (c_name); - } - c_cert = hildon_button_get_value (HILDON_BUTTON (cert)); - c_cert = strcmp (c_cert, "None") ? c_cert : NULL; - g_object_set (conn, - "name", c_name, - "host", gtk_entry_get_text (GTK_ENTRY (host)), - "cert", c_cert, - "user", gtk_entry_get_text (GTK_ENTRY (user)), - NULL); - strongswan_connections_save_connection (ListDialog.conns, conn); - } - gtk_widget_destroy (dialog); -} - -/** - * Creates a dialog showing a list of all connections - */ -static void -create_list_dialog (gpointer *parent) -{ - GtkWidget *dialog = gtk_dialog_new_with_buttons ( - "strongSwan Connections", - GTK_WINDOW (parent), - GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR, - GTK_STOCK_NEW, - RESPONSE_NEW, - GTK_STOCK_EDIT, - RESPONSE_EDIT, - GTK_STOCK_DELETE, - RESPONSE_DELETE, - GTK_STOCK_CLOSE, - GTK_RESPONSE_OK, - NULL); - ListDialog.dialog = dialog; - GtkWidget *vbox = GTK_DIALOG (dialog)->vbox; - - ListDialog.conns = strongswan_connections_new (); - - GtkTreeModel *model = strongswan_connections_get_model (ListDialog.conns); - ListDialog.list = gtk_tree_view_new_with_model (model); - g_object_unref (model); - - GtkTreeSelection *selection; - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (ListDialog.list)); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); - - GtkTreeViewColumn *column = gtk_tree_view_column_new (); - strongswan_connections_setup_column_renderers (ListDialog.conns, - GTK_CELL_LAYOUT (column)); - gtk_tree_view_append_column (GTK_TREE_VIEW (ListDialog.list), column); - - gtk_box_pack_start (GTK_BOX (vbox), - ListDialog.list, - TRUE, - TRUE, - HILDON_MARGIN_DEFAULT); - gtk_widget_show_all (dialog); - gtk_widget_hide (dialog); -} - -/** - * Get the name fo the selected connection in the list (or NULL). - * The name has to be freed. - */ -static gchar * -get_selected (void) -{ - GtkTreeView *tree = GTK_TREE_VIEW(ListDialog.list); - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreeIter iter; - gchar *name = NULL; - - selection = gtk_tree_view_get_selection (tree); - model = gtk_tree_view_get_model (tree); - if (gtk_tree_selection_get_selected (selection, &model, &iter)) - { - gtk_tree_model_get(model, &iter, 0, &name, -1); - } - return name; -} - -/** - * main callback for control panel plugins - */ -osso_return_t execute(osso_context_t *osso, gpointer data, - gboolean user_activated) -{ - gint response; - - create_list_dialog (data); - - if (!user_activated) - { - /* load state */ - } - - do - { - gchar *selected; - response = gtk_dialog_run (GTK_DIALOG (ListDialog.dialog)); - switch (response) - { - case RESPONSE_NEW: - { - edit_connection (data, NULL); - break; - } - case RESPONSE_EDIT: - { - StrongswanConnection *conn; - selected = get_selected (); - conn = strongswan_connections_get_connection (ListDialog.conns, - selected); - if (conn) - { - edit_connection (data, conn); - } - else - { - hildon_banner_show_information (NULL, NULL, - "Select a connection first"); - } - g_free (selected); - break; - } - case RESPONSE_DELETE: - { - GtkWidget *confirm; - gint retval; - gchar *msg; - selected = get_selected (); - if (!selected) - { - hildon_banner_show_information (NULL, NULL, - "Select a connection first"); - break; - } - msg = g_strdup_printf ("Delete connection?\n%s", selected); - confirm = hildon_note_new_confirmation (data, msg); - retval = gtk_dialog_run (GTK_DIALOG (confirm)); - if (retval == GTK_RESPONSE_OK) - { - strongswan_connections_remove_connection (ListDialog.conns, - selected); - } - gtk_widget_destroy (confirm); - g_free (msg); - g_free (selected); - break; - } - default: - break; - } - } - while (response > 0); - - gtk_widget_destroy (ListDialog.dialog); - g_object_unref (ListDialog.conns); - return OSSO_OK; -} - -/** - * callback called in case state has to be saved - */ -osso_return_t save_state(osso_context_t *osso, gpointer data) -{ - /* save state */ - return OSSO_OK; -} - diff --git a/src/frontends/maemo/src/strongswan-status.c b/src/frontends/maemo/src/strongswan-status.c deleted file mode 100644 index 278ca080d..000000000 --- a/src/frontends/maemo/src/strongswan-status.c +++ /dev/null @@ -1,621 +0,0 @@ -/* - * Copyright (C) 2010 Tobias Brunner - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#include <hildon/hildon.h> -#include <libosso.h> - -#include <string.h> - -#include "strongswan-status.h" -#include "strongswan-connections.h" - -#define STRONGSWAN_STATUS_GET_PRIVATE(object) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((object), \ - STRONGSWAN_TYPE_STATUS, \ - StrongswanStatusPrivate)) - -#define OSSO_STATUS_NAME "status" -#define OSSO_STATUS_SERVICE "org.strongswan."OSSO_STATUS_NAME -#define OSSO_STATUS_OBJECT "/org/strongswan/"OSSO_STATUS_NAME -#define OSSO_STATUS_IFACE "org.strongswan."OSSO_STATUS_NAME - -#define OSSO_CHARON_NAME "charon" -#define OSSO_CHARON_SERVICE "org.strongswan."OSSO_CHARON_NAME -#define OSSO_CHARON_OBJECT "/org/strongswan/"OSSO_CHARON_NAME -#define OSSO_CHARON_IFACE "org.strongswan."OSSO_CHARON_NAME - -#define ICON_SIZE_STATUS 18 -#define ICON_SIZE_BUTTON 48 - -#define UNREF_IF(obj) do { \ - if (obj) { obj = (g_object_unref (obj), NULL); } \ -} while(0) - -typedef enum -{ - STATUS_DISCONNECTED, - STATUS_CONNECTING, - STATUS_CONNECTED, - STATUS_AUTH_FAILED, - STATUS_CONNECTION_FAILED, -} StrongswanConnectionStatus; - -struct _StrongswanStatusPrivate -{ - struct { - GdkPixbuf *status_open; - GdkPixbuf *status_close; - GdkPixbuf *button_open; - GdkPixbuf *button_close; - } icons; - - GtkWidget *dialog; - GtkWidget *button; - GtkWidget *image; - GtkWidget *selector; - GtkWidget *box; - - osso_context_t *context; - - StrongswanConnections *conns; - - StrongswanConnectionStatus status; - gchar *current; -}; - -HD_DEFINE_PLUGIN_MODULE_EXTENDED (StrongswanStatus, strongswan_status, \ - HD_TYPE_STATUS_MENU_ITEM, {}, { \ - strongswan_connection_register (G_TYPE_MODULE (plugin)); \ - strongswan_connections_register (G_TYPE_MODULE (plugin)); }, {}); - -static void -update_status_menu (StrongswanStatus *plugin) -{ - StrongswanStatusPrivate *priv = plugin->priv; - switch (priv->status) - { - default: - case STATUS_DISCONNECTED: - { - hildon_button_set_value (HILDON_BUTTON (priv->button), - "Not connected"); - hd_status_plugin_item_set_status_area_icon ( - HD_STATUS_PLUGIN_ITEM (plugin), - priv->icons.status_open); - gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), - priv->icons.button_open); - break; - } - case STATUS_CONNECTING: - { - gchar *msg = g_strdup_printf ("Connecting to %s...", priv->current); - hildon_button_set_value (HILDON_BUTTON (priv->button), msg); - g_free (msg); - break; - } - case STATUS_CONNECTED: - { - gchar *msg = g_strdup_printf ("Connected to %s", priv->current); - hildon_button_set_value (HILDON_BUTTON (priv->button), msg); - g_free (msg); - hd_status_plugin_item_set_status_area_icon ( - HD_STATUS_PLUGIN_ITEM (plugin), - priv->icons.status_close); - gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), - priv->icons.button_close); - break; - } - } -} - -static void -update_dialog_connecting (StrongswanStatus *plugin) -{ - StrongswanStatusPrivate *priv = plugin->priv; - - gtk_widget_set_sensitive (priv->box, FALSE); - hildon_gtk_window_set_progress_indicator (GTK_WINDOW (priv->dialog), 1); -} - -static void -update_dialog_default (StrongswanStatus *plugin) -{ - StrongswanStatusPrivate *priv = plugin->priv; - - gtk_widget_set_sensitive (priv->box, TRUE); - hildon_gtk_window_set_progress_indicator (GTK_WINDOW (priv->dialog), 0); -} - -static void -dialog_response (GtkDialog *dialog, gint response_id, StrongswanStatus *plugin) -{ - StrongswanStatusPrivate *priv = plugin->priv; - gtk_widget_destroy (priv->dialog); - priv->dialog = NULL; -} - -static void -handle_status_change (StrongswanStatus *plugin, - StrongswanConnectionStatus status, - gchar *message) -{ - StrongswanStatusPrivate *priv = plugin->priv; - gchar *msg = NULL; - - switch (status) - { - case STATUS_CONNECTION_FAILED: - { - if (priv->status == STATUS_CONNECTED) - { - msg = g_strdup_printf ("Lost connection to %s", priv->current); - } - else if (message) - { - msg = g_strdup_printf ("Failed to connect to %s: %s", - priv->current, message); - } - else - { - msg = g_strdup_printf ("Failed to connect to %s", - priv->current); - } - status = STATUS_DISCONNECTED; - break; - } - case STATUS_AUTH_FAILED: - { - msg = g_strdup_printf ("Failed to connect to %s: authentication " - "failed", priv->current); - status = STATUS_DISCONNECTED; - /* TODO: show password dialog again? */ - break; - } - case STATUS_CONNECTED: - { - msg = g_strdup_printf ("Successfully connected to %s", - priv->current); - break; - } - default: - case STATUS_DISCONNECTED: - { - msg = g_strdup_printf ("Disconnected from %s", priv->current); - break; - } - } - - priv->status = status; - - if (status == STATUS_DISCONNECTED) - { - priv->current = (g_free (priv->current), NULL); - } - - hildon_banner_show_information (NULL, NULL, msg); - g_free (msg); - - update_status_menu (plugin); - - if (priv->dialog) - { - update_dialog_default (plugin); - if (status == STATUS_CONNECTED) - { - gtk_dialog_response (GTK_DIALOG (priv->dialog), GTK_RESPONSE_OK); - } - } -} - -static gboolean -get_password (StrongswanStatus *plugin, gchar **password) -{ - StrongswanStatusPrivate *priv = plugin->priv; - gboolean result = FALSE; - - GtkWidget *dialog = gtk_dialog_new_with_buttons ( - "Connecting...", - GTK_WINDOW(priv->dialog), - GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, - GTK_RESPONSE_OK, - NULL); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - GtkWidget *vbox = GTK_DIALOG (dialog)->vbox; - GtkSizeGroup *group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - - GtkWidget *pass = hildon_entry_new (HILDON_SIZE_AUTO); - hildon_gtk_entry_set_placeholder_text (GTK_ENTRY (pass), "Password"); - hildon_gtk_entry_set_input_mode (GTK_ENTRY (pass), - HILDON_GTK_INPUT_MODE_FULL | - HILDON_GTK_INPUT_MODE_INVISIBLE); - GtkWidget *pcap = hildon_caption_new (group, - "Password", - pass, - NULL, - HILDON_CAPTION_OPTIONAL); - gtk_box_pack_start (GTK_BOX (vbox), pcap, TRUE, TRUE, 0); - gtk_widget_show_all (dialog); - - gint retval = gtk_dialog_run (GTK_DIALOG (dialog)); - if (retval == GTK_RESPONSE_OK) - { - *password = g_strdup (gtk_entry_get_text (GTK_ENTRY (pass))); - result = TRUE; - } - gtk_widget_destroy (dialog); - return result; -} - -static void -connect_clicked (HildonButton *button, StrongswanStatus *plugin) -{ - StrongswanStatusPrivate *priv = plugin->priv; - osso_return_t result; - osso_rpc_t retval; - - priv->current = hildon_touch_selector_get_current_text ( - HILDON_TOUCH_SELECTOR (priv->selector)); - priv->status = STATUS_CONNECTING; - update_dialog_connecting (plugin); - update_status_menu (plugin); - - StrongswanConnection *conn = strongswan_connections_get_connection ( - priv->conns, - priv->current); - if (!conn) - { - handle_status_change (plugin, STATUS_CONNECTION_FAILED, "not found"); - return; - } - - /* this call on the system bus is only needed to start charon as root */ - result = osso_rpc_run_system (priv->context, - OSSO_CHARON_SERVICE, - OSSO_CHARON_OBJECT, - OSSO_CHARON_IFACE, - "Start", - &retval, - DBUS_TYPE_INVALID); - osso_rpc_free_val (&retval); - if (result != OSSO_OK) - { - handle_status_change (plugin, STATUS_CONNECTION_FAILED, - "couldn't connect to charon"); - return; - } - - gchar *c_host, *c_cert, *c_user, *c_pass; - - if (!get_password (plugin, &c_pass)) - { - update_dialog_default (plugin); - return; - } - - g_object_get (conn, - "host", &c_host, - "cert", &c_cert, - "user", &c_user, - NULL); - - result = osso_rpc_run (priv->context, - OSSO_CHARON_SERVICE, - OSSO_CHARON_OBJECT, - OSSO_CHARON_IFACE, - "Connect", - &retval, - DBUS_TYPE_STRING, priv->current, - DBUS_TYPE_STRING, c_host, - DBUS_TYPE_STRING, c_cert, - DBUS_TYPE_STRING, c_user, - DBUS_TYPE_STRING, c_pass, - DBUS_TYPE_INVALID); - - g_free (c_host); - g_free (c_cert); - g_free (c_user); - g_free (c_pass); - - if (result != OSSO_OK || !retval.value.b) - { - handle_status_change (plugin, STATUS_CONNECTION_FAILED, - "initiation failed"); - osso_rpc_free_val (&retval); - return; - } - osso_rpc_free_val (&retval); -} - -static void -disconnect_clicked (HildonButton *button, StrongswanStatus *plugin) -{ - osso_return_t result; - osso_rpc_t retval; - gchar *msg; - StrongswanStatusPrivate *priv = plugin->priv; - - gtk_widget_set_sensitive (priv->box, FALSE); - hildon_gtk_window_set_progress_indicator (GTK_WINDOW (priv->dialog), 1); - - result = osso_rpc_run_system (priv->context, - OSSO_CHARON_SERVICE, - OSSO_CHARON_OBJECT, - OSSO_CHARON_IFACE, - "Disconnect", - &retval, - DBUS_TYPE_INVALID); - - gtk_widget_set_sensitive (priv->box, TRUE); - hildon_gtk_window_set_progress_indicator (GTK_WINDOW (priv->dialog), 0); - - if (result == OSSO_OK) - { - msg = g_strdup_printf ("Successfully disconnected from %s", - priv->current); - } - else - { - msg = g_strdup_printf ("Failed to disconnect from %s", priv->current); - } - hildon_banner_show_information (NULL, NULL, msg); - g_free (msg); - - priv->current = (g_free (priv->current), NULL); - priv->status = STATUS_DISCONNECTED; - - update_status_menu (plugin); - - gtk_dialog_response (GTK_DIALOG (priv->dialog), GTK_RESPONSE_OK); -} - -static void -setup_dialog_disconnected (StrongswanStatus *plugin) -{ - StrongswanStatusPrivate *priv = plugin->priv; - - GtkWidget *vbox = GTK_DIALOG (priv->dialog)->vbox; - 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)); - - 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); -} - -static void -setup_dialog_connected (StrongswanStatus *plugin) -{ - StrongswanStatusPrivate *priv = plugin->priv; - - GtkWidget *vbox = GTK_DIALOG (priv->dialog)->vbox; - 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); -} - -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); - - switch (priv->status) - { - default: - case STATUS_DISCONNECTED: - setup_dialog_disconnected (plugin); - break; - case STATUS_CONNECTING: - setup_dialog_disconnected (plugin); - update_dialog_connecting (plugin); - break; - case STATUS_CONNECTED: - setup_dialog_connected (plugin); - break; - } - - gtk_widget_show_all (priv->dialog); -} - -static gint -dbus_req_handler(const gchar *interface, const gchar *method, - GArray *arguments, StrongswanStatus *plugin, - osso_rpc_t *retval) -{ - if (!strcmp (method, "StatusChanged") && arguments->len == 1) - { - int status = 0; - osso_rpc_t *arg = &g_array_index(arguments, osso_rpc_t, 0); - if (arg->type == DBUS_TYPE_INT32) - { - status = arg->value.i; - } - handle_status_change (plugin, status, NULL); - } - return OSSO_OK; -} - -static GdkPixbuf* -load_icon (GtkIconTheme *theme, const gchar *name, gint size) -{ - GdkPixbuf *icon = gtk_icon_theme_load_icon (theme, name, size, - GTK_ICON_LOOKUP_NO_SVG, NULL); - return icon; -} - -static void -load_icons (StrongswanStatusPrivate *priv) -{ - GtkIconTheme *theme = gtk_icon_theme_get_default (); - priv->icons.status_open = load_icon (theme, "strongswan_lock_open", - ICON_SIZE_STATUS); - priv->icons.status_close = load_icon (theme, "strongswan_lock_close", - ICON_SIZE_STATUS); - priv->icons.button_open = load_icon (theme, "strongswan_lock_open", - ICON_SIZE_BUTTON); - priv->icons.button_close = load_icon (theme, "strongswan_lock_close", - ICON_SIZE_BUTTON); -} - -static void -icon_theme_changed (GtkIconTheme *theme, StrongswanStatus *plugin) -{ - StrongswanStatusPrivate *priv = plugin->priv; - UNREF_IF(priv->icons.status_open); - UNREF_IF(priv->icons.status_close); - UNREF_IF(priv->icons.button_open); - UNREF_IF(priv->icons.button_close); - load_icons (priv); - update_status_menu (plugin); -} - -static void -strongswan_status_init (StrongswanStatus *plugin) -{ - StrongswanStatusPrivate *priv = STRONGSWAN_STATUS_GET_PRIVATE (plugin); - plugin->priv = priv; - - priv->context = osso_initialize (OSSO_STATUS_SERVICE, "0.0.1", TRUE, NULL); - if (!priv->context) - { - return; - } - osso_return_t result; - result = osso_rpc_set_cb_f (priv->context, - OSSO_STATUS_SERVICE, - OSSO_STATUS_OBJECT, - OSSO_STATUS_IFACE, - (osso_rpc_cb_f*)dbus_req_handler, - plugin); - if (result != OSSO_OK) - { - return; - } - - priv->conns = strongswan_connections_new (); - - load_icons(priv); - - hd_status_plugin_item_set_status_area_icon (HD_STATUS_PLUGIN_ITEM (plugin), - priv->icons.status_open); - - GtkWidget *button = hildon_button_new_with_text ( - HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, - HILDON_BUTTON_ARRANGEMENT_VERTICAL, - "strongSwan VPN", "Not connected"); - hildon_button_set_style (HILDON_BUTTON (button), - HILDON_BUTTON_STYLE_PICKER); - priv->button = button; - gtk_container_add (GTK_CONTAINER (plugin), button); - - GtkWidget *image = gtk_image_new_from_pixbuf (priv->icons.button_open); - priv->image = image; - hildon_button_set_image (HILDON_BUTTON (button), image); - - gtk_button_set_alignment (GTK_BUTTON (button), 0.0, 0.5); - - g_signal_connect (button, "clicked", G_CALLBACK (button_clicked), plugin); - - gtk_widget_show_all (GTK_WIDGET (plugin)); - - g_signal_connect (gtk_icon_theme_get_default (), "changed", - G_CALLBACK (icon_theme_changed), plugin); -} - -static void -strongswan_status_dispose (GObject *object) -{ - StrongswanStatusPrivate *priv = STRONGSWAN_STATUS (object)->priv; - if (priv->context) - { - osso_rpc_unset_cb_f (priv->context, - OSSO_STATUS_SERVICE, - OSSO_STATUS_OBJECT, - OSSO_STATUS_IFACE, - (osso_rpc_cb_f*)dbus_req_handler, - STRONGSWAN_STATUS (object)); - osso_deinitialize (priv->context); - priv->context = NULL; - } - UNREF_IF(priv->conns); - UNREF_IF(priv->icons.status_open); - UNREF_IF(priv->icons.status_close); - UNREF_IF(priv->icons.button_open); - UNREF_IF(priv->icons.button_close); - G_OBJECT_CLASS (strongswan_status_parent_class)->dispose (object); -} - -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); -} - -static void -strongswan_status_class_finalize (StrongswanStatusClass *klass) -{ -} - -static void -strongswan_status_class_init (StrongswanStatusClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->dispose = strongswan_status_dispose; - object_class->finalize = strongswan_status_finalize; - - g_type_class_add_private (klass, sizeof (StrongswanStatusPrivate)); -} diff --git a/src/frontends/maemo/src/strongswan-status.h b/src/frontends/maemo/src/strongswan-status.h deleted file mode 100644 index 9daa8e59d..000000000 --- a/src/frontends/maemo/src/strongswan-status.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2010 Tobias Brunner - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef __STRONGSWAN_STATUS_H__ -#define __STRONGSWAN_STATUS_H__ - -#include <libhildondesktop/libhildondesktop.h> - -G_BEGIN_DECLS - -#define STRONGSWAN_TYPE_STATUS (strongswan_status_get_type ()) -#define STRONGSWAN_STATUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), STRONGSWAN_TYPE_STATUS, StrongswanStatus)) -#define STRONGSWAN_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), STRONGSWAN_TYPE_STATUS, StrongswanStatusClass)) -#define STRONGSWAN_IS_STATUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), STRONGSWAN_TYPE_STATUS)) -#define STRONGSWAN_IS_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), STRONGSWAN_TYPE_STATUS)) -#define STRONGSWAN_STATUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), STRONGSWAN_TYPE_STATUSS, StrongswanStatusClass)) - -typedef struct _StrongswanStatus StrongswanStatus; -typedef struct _StrongswanStatusClass StrongswanStatusClass; -typedef struct _StrongswanStatusPrivate StrongswanStatusPrivate; - -struct _StrongswanStatus -{ - HDStatusMenuItem parent; - - StrongswanStatusPrivate *priv; -}; - -struct _StrongswanStatusClass -{ - HDStatusMenuItemClass parent; -}; - -GType strongswan_status_get_type (void); - -G_END_DECLS - -#endif /* __STRONGSWAN_STATUS_H__ */ - |