From: Martin Willi Date: Thu, 13 Mar 2008 14:37:11 +0000 (-0000) Subject: added old and unmaintained prototype of NetworkManager applet and authenticator X-Git-Tag: 4.2.0~146 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d94fdfab7bdca2f98ea462f0066a7867dc8020b;p=thirdparty%2Fstrongswan.git added old and unmaintained prototype of NetworkManager applet and authenticator --- diff --git a/src/charon/plugins/dbus/nm_applet_auth.c b/src/charon/plugins/dbus/nm_applet_auth.c new file mode 100644 index 0000000000..f48ee1ba3e --- /dev/null +++ b/src/charon/plugins/dbus/nm_applet_auth.c @@ -0,0 +1,11 @@ +#include + + +int main() +{ + char buf[1]; + printf("PASSWORDL\n"); + printf ("\n\n"); + //fread (buf, sizeof (char), sizeof (buf), stdin); + return 0; +} diff --git a/src/charon/plugins/dbus/nm_applet_gui.c b/src/charon/plugins/dbus/nm_applet_gui.c new file mode 100644 index 0000000000..7a35ab6961 --- /dev/null +++ b/src/charon/plugins/dbus/nm_applet_gui.c @@ -0,0 +1,195 @@ +/* + * Copyright (C) 2007 Martin Willi + * 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 . + * + * 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. + * + * $Id$ + */ + +#include + +#define NM_VPN_API_SUBJECT_TO_CHANGE +#include + + +typedef struct private_nm_applet_gui_t private_nm_applet_gui_t; + +/** + * Private data of an nm_applet_gui_t object. + */ +struct private_nm_applet_gui_t { + + /** + * Implements NetworkManagerVpnUI interface. + */ + NetworkManagerVpnUI public; + + /** + * callback registered by NM to update validity + */ + NetworkManagerVpnUIDialogValidityCallback callback; + + /** + * loaded Glade XML interface description + */ + GladeXML *xml; + + /** + * root widget to return to druid + */ + GtkWidget *widget; + + /** + * name of the connection + */ + GtkEntry *name; +}; + +static const char *get_display_name(private_nm_applet_gui_t *this) +{ + return "strongSwan (IPsec/IKEv2)"; +} + +static const char *get_service_name(private_nm_applet_gui_t *this) +{ + return "org.freedesktop.NetworkManager.strongswan"; +} + +static GtkWidget *get_widget(private_nm_applet_gui_t *this, GSList *properties, + GSList *routes, const char *connection_name) +{ + GSList *i; + + gtk_entry_set_text(this->name, ""); + /*gtk_entry_set_text(this->gateway, "");*/ + + if (connection_name) + { + gtk_entry_set_text(this->name, connection_name); + } + + while (properties) + { + const char *key; + const char *value; + + key = properties->data; + properties = g_slist_next(properties); + if (properties) + { + value = properties->data; + /* + if (strcmp(key, "gateway") == 0) + { + gtk_entry_set_text(this->gateway, value); + }*/ + properties = g_slist_next(properties); + } + } + + return this->widget; +} + +static GSList *get_properties(private_nm_applet_gui_t *this) +{ + GSList *props = NULL; + + /*props = g_slist_append(props, g_strdup("gateway")); + props = g_slist_append(props, g_strdup(gtk_entry_get_text(this->gateway)));*/ + + return props; +} + +static GSList *get_routes(private_nm_applet_gui_t *this) +{ + return NULL; +} + +static char *get_connection_name(private_nm_applet_gui_t *this) +{ + const char *name; + + name = gtk_entry_get_text(this->name); + if (name != NULL) + { + return g_strdup(name); + } + return NULL; +} + +static gboolean is_valid(private_nm_applet_gui_t *this) +{ + return TRUE; +} + +static void set_validity_changed_callback(private_nm_applet_gui_t *this, + NetworkManagerVpnUIDialogValidityCallback callback, + gpointer user_data) +{ + this->callback = callback; +} + +static void get_confirmation_details(private_nm_applet_gui_t *this, gchar **retval) +{ + *retval = g_strdup_printf("connection %s\n", gtk_entry_get_text(this->name)); +} + +static gboolean can_export(private_nm_applet_gui_t *this) +{ + return FALSE; +} + +static gboolean import_file (private_nm_applet_gui_t *this, const char *path) +{ + return FALSE; +} + +static gboolean export(private_nm_applet_gui_t *this, GSList *properties, + GSList *routes, const char *connection_name) +{ + return FALSE; +} + +NetworkManagerVpnUI* nm_vpn_properties_factory(void) +{ + private_nm_applet_gui_t *this = g_new0(private_nm_applet_gui_t, 1); + + this->public.get_display_name = (const char *(*)(NetworkManagerVpnUI *))get_display_name; + this->public.get_service_name = (const char *(*) (NetworkManagerVpnUI *))get_service_name; + this->public.get_widget = (GtkWidget *(*) (NetworkManagerVpnUI *self, GSList *, GSList *, const char *))get_widget; + this->public.get_connection_name = (char *(*) (NetworkManagerVpnUI *))get_connection_name; + this->public.get_properties = (GSList *(*) (NetworkManagerVpnUI *))get_properties; + this->public.get_routes = (GSList *(*) (NetworkManagerVpnUI *))get_routes; + this->public.set_validity_changed_callback = (void (*) (NetworkManagerVpnUI *, NetworkManagerVpnUIDialogValidityCallback, gpointer))set_validity_changed_callback; + this->public.is_valid = (gboolean (*) (NetworkManagerVpnUI *))is_valid; + this->public.get_confirmation_details = (void (*)(NetworkManagerVpnUI *, gchar **))get_confirmation_details; + this->public.can_export = (gboolean (*) (NetworkManagerVpnUI *))can_export; + this->public.import_file = (gboolean (*) (NetworkManagerVpnUI *, const char *))import_file; + this->public.export = (gboolean (*) (NetworkManagerVpnUI *, GSList *, GSList *, const char *))export; + this->public.data = NULL; + + this->callback = NULL; + this->xml = glade_xml_new("/home/martin/strongswan/trunk/src/networkmanager/nm_applet_gui.xml", NULL, NULL); + + if (this->xml != NULL) + { + this->widget = glade_xml_get_widget(this->xml, "main"); + this->name = GTK_ENTRY(glade_xml_get_widget(this->xml, "name")); + + if (this->widget && this->name) + { + return &this->public; + } + } + g_free(this); + return NULL; +} diff --git a/src/charon/plugins/dbus/nm_applet_gui.xml b/src/charon/plugins/dbus/nm_applet_gui.xml new file mode 100644 index 0000000000..9eb89c262f --- /dev/null +++ b/src/charon/plugins/dbus/nm_applet_gui.xml @@ -0,0 +1,38 @@ + + + + + + + + True + 1 + 2 + + + True + Connection _name + True + + + GTK_FILL + GTK_FILL + + + + + True + + + 1 + 2 + GTK_FILL + GTK_FILL + 5 + 5 + + + + + +