added old and unmaintained prototype of NetworkManager applet and authenticator

This commit is contained in:
Martin Willi
2008-03-13 14:37:11 +00:00
parent b820f8aa8e
commit 2d94fdfab7
3 changed files with 244 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
#include <stdio.h>
int main()
{
char buf[1];
printf("PASSWORDL\n");
printf ("\n\n");
//fread (buf, sizeof (char), sizeof (buf), stdin);
return 0;
}
+195
View File
@@ -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 <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.
*
* $Id$
*/
#include <glade/glade.h>
#define NM_VPN_API_SUBJECT_TO_CHANGE
#include <nm-vpn-ui-interface.h>
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;
}
+38
View File
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.2.0 on Mon Apr 30 15:31:54 2007 by martin@martin-->
<glade-interface>
<widget class="GtkWindow" id="window1">
<child>
<widget class="GtkTable" id="main">
<property name="visible">True</property>
<property name="n_rows">1</property>
<property name="n_columns">2</property>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">Connection _name</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="name">
<property name="visible">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="x_padding">5</property>
<property name="y_padding">5</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>