Commit 58d9db9a authored by Dan Williams's avatar Dan Williams
Browse files

2008-07-20 Dan Williams <dcbw@redhat.com>

	Port to NM 0.7 VPN plugin API



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3838 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent e0583686
2008-07-20 Dan Williams <dcbw@redhat.com>
Port to NM 0.7 VPN plugin API
2008-04-27 Dan Williams <dcbw@redhat.com>
* properties/Makefile.am
......
AUTOMAKE_OPTIONS = foreign
if WITH_GNOME
SUBDIRS = src auth-dialog auth-dialog-general properties po
SUBDIRS = src auth-dialog properties po
else
SUBDIRS = src
endif
dbusservicedir = $(sysconfdir)/dbus-1/system.d
dbusservice_DATA = nm-ppp-starter.conf
dbusservice_DATA = nm-pptp-service.conf
nmvpnservice_in_files = nm-ppp-starter.name.in
nmvpnservicedir = $(sysconfdir)/NetworkManager/VPN
nmvpnservice_DATA = $(nmvpnservice_in_files:.name.in=.name)
%.name: %.name.in Makefile
@sed -e "s|%bindir%|$(bindir)|g" \
-e "s|%libdir%|$(libdir)|g" \
-e "s|%libexecdir%|$(libexecdir)|g" $< > $@
nmvpnservice_DATA = nm-pptp-service.name
if WITH_GNOME
desktopdir = $(datadir)/applications
desktop_in_files = nm-ppp.desktop.in
desktop_in_files = nm-pptp.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
......@@ -26,14 +22,18 @@ icondir = $(datadir)/icons/hicolor/48x48/apps
icon_DATA = gnome-mime-application-x-pptp-settings.png
endif
EXTRA_DIST =\
$(nmvpnservice_in_files) \
$(dbusservice_DATA) \
$(desktop_in_files) \
$(icon_DATA) \
intltool-extract.in \
intltool-merge.in \
intltool-update.in
nm-pptp-service.name: $(srcdir)/nm-pptp-service.name.in Makefile
sed -e 's|[@]BINDIR[@]|$(bindir)|g' \
< $(srcdir)/nm-pptp-service.name.in \
> nm-pptp-service.name
EXTRA_DIST = nm-pptp-service.name.in \
$(dbusservice_DATA) \
$(desktop_in_files) \
$(icon_DATA) \
intltool-extract.in \
intltool-merge.in \
intltool-update.in
CLEANFILES = $(desktop_DATA) $(nmvpnservice_DATA) *~
CLEANFILES = $(nmvpnservice_DATA) $(desktop_DATA) *~
DISTCLEANFILES = intltool-extract intltool-merge intltool-update
PPTP support for NetworkManager
Added by Antony Mee http://www.students.ncl.ac.uk/a.j.mee
Based entirely on OpenVPN support by Tim Niemueller http://www.niemueller.de
This requires the Linux PPTP client installed
http://pptpclient.sourceforge.net/
TODO: Support for passwords stored outside of /etc/ppp/chap-secrets
0.7.x version:
(C) 2008 Dan Williams <dcbw@redhat.com>, and Tambet Ingo <tambet@gmail.com>
0.6.x version:
(C) 2005 - 2007 Antony Mee http://www.students.ncl.ac.uk/a.j.mee
Based entirely on OpenVPN support by Tim Niemueller http://www.niemueller.de
Code released under the GPL. See COPYING file in the NetworkManager
directory.
Theory of operation
------------------------------
Aachen, 2005/11/12
Makefile.in
Makefile
nm-ppp-auth-dialog-general
.libs
.deps
INCLUDES = -I${top_srcdir} -I${top_srcdir}/utils
libexec_PROGRAMS = nm-ppp-auth-dialog-general
nm_ppp_auth_dialog_general_CPPFLAGS = \
$(GTHREAD_CFLAGS) \
$(GTK_CFLAGS) \
$(LIBGNOMEUI_CFLAGS) \
$(GNOMEKEYRING_CFLAGS) \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DGLADEDIR=\""$(gladedir)"\" \
-DAUTH_MODULES_DIR=\""$(libgenericauthmodulesdir)"\" \
-DBINDIR=\""$(bindir)"\" \
-DDBUS_API_SUBJECT_TO_CHANGE \
-DG_DISABLE_DEPRECATED \
-DGDK_DISABLE_DEPRECATED \
-DGNOME_DISABLE_DEPRECATED \
-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
-DVERSION=\"$(VERSION)\" \
$(NULL)
nm_ppp_auth_dialog_general_SOURCES = \
main.c \
gnome-generic-auth-dialog.c \
gnome-generic-auth-dialog.h \
$(NULL)
nm_ppp_auth_dialog_general_LDADD = \
$(GTK_LIBS) \
$(LIBGNOMEUI_LIBS) \
$(GNOMEKEYRING_LIBS) \
$(NULL)
libgenericauthmodulesdir=$(libdir)/NetworkManager/gnome-generic-auth
libgenericauthmodules_LTLIBRARIES = \
libanonymous-auth-module.la \
libchap-auth-module.la \
libmschapv2-auth-module.la
libanonymous_auth_module_la_SOURCES = \
anonymous-auth-module.c
libmschapv2_auth_module_la_SOURCES = \
mschapv2-auth-module.c
libchap_auth_module_la_SOURCES = \
chap-auth-module.c
gladedir = $(datadir)/gnome-generic-auth
glade_DATA = nm-ppp-auth.glade
libanonymous_auth_module_la_CFLAGS = \
$(GLADE_CFLAGS) \
$(GTK_CFLAGS) \
$(GCONF_CFLAGS) \
$(LIBGNOMEUI_CFLAGS) \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DGLADEDIR=\""$(gladedir)"\" \
-DAUTH_MODULES_DIR=\""$(libgenericauthmodulesdir)"\" \
-DG_DISABLE_DEPRECATED \
-DGDK_DISABLE_DEPRECATED \
-DGNOME_DISABLE_DEPRECATED \
-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
-DVERSION=\"$(VERSION)\"
libanonymous_auth_module_la_LIBADD = \
$(GLADE_LIBS) \
$(GTK_LIBS) \
$(GCONF_LIBS) \
$(LIBGNOMEUI_LIBS)
libchap_auth_module_la_CFLAGS = \
$(GLADE_CFLAGS) \
$(GTK_CFLAGS) \
$(GCONF_CFLAGS) \
$(LIBGNOMEUI_CFLAGS) \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DGLADEDIR=\""$(gladedir)"\" \
-DAUTH_MODULES_DIR=\""$(libgenericauthmodulesdir)"\" \
-DG_DISABLE_DEPRECATED \
-DGDK_DISABLE_DEPRECATED \
-DGNOME_DISABLE_DEPRECATED \
-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
-DVERSION=\"$(VERSION)\"
libmschapv2_auth_module_la_CFLAGS = \
$(GLADE_CFLAGS) \
$(GTK_CFLAGS) \
$(GCONF_CFLAGS) \
$(LIBGNOMEUI_CFLAGS) \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DGLADEDIR=\""$(gladedir)"\" \
-DAUTH_MODULES_DIR=\""$(libgenericauthmodulesdir)"\" \
-DG_DISABLE_DEPRECATED \
-DGDK_DISABLE_DEPRECATED \
-DGNOME_DISABLE_DEPRECATED \
-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
-DVERSION=\"$(VERSION)\"
libchap_auth_module_la_LIBADD = \
$(GLADE_LIBS) \
$(GTK_LIBS) \
$(GCONF_LIBS) \
$(LIBGNOMEUI_LIBS)
libmschapv2_auth_module_la_LIBADD = \
$(GLADE_LIBS) \
$(GTK_LIBS) \
$(GCONF_LIBS) \
$(LIBGNOMEUI_LIBS)
EXTRA_DIST = \
$(glade_DATA)
CLEANFILES = *.bak *.gladep *~
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <glib/gi18n-lib.h>
#include <string.h>
#include <glade/glade.h>
#define GNOME_GENERIC_AUTH_MODULE_SUBJECT_TO_CHANGE
#include "gnome-generic-auth-module.h"
/* Stuff to be provided by the specific instance */
typedef struct _GnomeGenericAuthModuleImpl GnomeGenericAuthModuleImpl;
struct _GnomeGenericAuthModuleImpl {
GnomeGenericAuthModule parent;
GladeXML *xml;
GtkWidget *widget;
// GtkEntry *w_connection_name;
// GtkEntry *w_remote;
};
#define GLADE_FILE "nm-ppp-auth.glade"
#define GLADE_WIDGET "auth-none-widget"
#define AUTH_TYPE "NONE"
#define AUTH_TYPE_DISPLAY_NAME "None (Anonymous)"
void
impl_clear_widget (GnomeGenericAuthModuleImpl *impl)
{
// g_return_if_fail(impl!=NULL);
}
static const char *
impl_get_display_name (GnomeGenericAuthModule *self)
{
return AUTH_TYPE_DISPLAY_NAME;
}
static const char *
impl_get_auth_type (GnomeGenericAuthModule *self)
{
return AUTH_TYPE;
}
static GtkWidget *
impl_get_widget (GnomeGenericAuthModule *self)
{
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data;
impl_clear_widget (impl);
//
// if (connection_name != NULL) {
// if ((opt = impl->connection_name_opt) != NULL) {
// vpnui_opt_set(opt,connection_name);
// }
// }
//
// for (item=properties; item != NULL; item = g_slist_next(g_slist_next(item)))
// {
// if (item->data==NULL) continue;
// if ((g_slist_next(item))->data==NULL) continue;
// opt = impl_opt_bygconf(impl,(char *)item->data);
// if (opt==NULL) continue;
// vpnui_opt_set(opt, (char *)(g_slist_next(item))->data);
// }
//
// if (routes != NULL) {
// GString *route_str;
// char *str;
//
// route_str = g_string_new ("");
// for (item = routes; item != NULL; item = g_slist_next (item)) {
// if (item != routes) g_string_append_c(route_str, ' ');
// g_string_append(route_str, (const char *) item->data);
// }
// str = g_string_free (route_str, FALSE);
//
// vpnui_opt_set(impl->routes_opt,str);
// vpnui_opt_set(impl->routes_toggle_opt,"yes");
// g_free (str);
// }
//
// vpnui_expand_reset_all(impl);
//
return impl->widget;
}
static GnomeGenericAuthModule*
impl_get_object (void)
{
char *glade_file;
GnomeGenericAuthModuleImpl *impl;
impl = g_new0 (GnomeGenericAuthModuleImpl, 1);
glade_file = g_strdup_printf ("%s/%s", GLADEDIR, GLADE_FILE);
impl->xml = glade_xml_new (glade_file, NULL, GETTEXT_PACKAGE);
g_free( glade_file );
if (impl->xml != NULL) {
impl->widget = glade_xml_get_widget(impl->xml, GLADE_WIDGET);
// impl_setup(impl);
// impl->callback = NULL;
// if (impl->w_import_button!=NULL) {
// g_signal_connect (GTK_OBJECT (impl->w_import_button),
// "clicked", G_CALLBACK (import_button_clicked), impl);
// }
//
// /* make the widget reusable */
// g_signal_connect (GTK_OBJECT (impl->widget), "delete-event",
// G_CALLBACK (gtk_widget_hide_on_delete), NULL);
//
impl_clear_widget (impl);
impl->parent.get_display_name = impl_get_display_name;
impl->parent.get_auth_type = impl_get_auth_type;
impl->parent.get_widget = impl_get_widget;
impl->parent.data = impl;
return &(impl->parent);
} else {
g_free (impl);
return NULL;
}
}
const char *
get_auth_type (void)
{
return AUTH_TYPE;
}
GnomeGenericAuthModule*
gnome_generic_auth_module_factory (void)
{
return impl_get_object();
}
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <glib/gi18n-lib.h>
#include <string.h>
#include <glade/glade.h>
#define GNOME_GENERIC_AUTH_MODULE_SUBJECT_TO_CHANGE
#include "gnome-generic-auth-module.h"
/* Stuff to be provided by the specific instance */
typedef struct _GnomeGenericAuthModuleImpl GnomeGenericAuthModuleImpl;
struct _GnomeGenericAuthModuleImpl {
GnomeGenericAuthModule parent;
GladeXML *xml;
GtkWidget *widget;
GtkEntry *w_username;
GtkEntry *w_password;
};
#define GLADE_FILE "nm-ppp-auth.glade"
#define GLADE_WIDGET "auth-chap-widget"
//#define GLADE_WIDGET "table1"
#define AUTH_TYPE "CHAP"
#define AUTH_TYPE_DISPLAY_NAME "CHAP Version 1"
static void
entry_changed (GtkWidget *widget,gpointer data)
{
// GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) data;
g_warning("Entry: %s (%s)",gtk_entry_get_text(GTK_ENTRY(widget)), gtk_widget_get_name(widget));
}
static void
clear_widget (GnomeGenericAuthModuleImpl *impl)
{
GList *children;
GList *i;
GtkWidget *w;
g_warning("Clearing widget");
gtk_entry_set_text(impl->w_username,"");
gtk_entry_set_text(impl->w_password,"");
gtk_widget_grab_focus (GTK_WIDGET(impl->w_username));
//g_warning("Username %s", GTK_WIDGET_CAN_FOCUS(impl->w_username) ? "Can focus" : "Can't focus" );
//g_warning("Username %s", GTK_WIDGET_VISIBLE(impl->w_username) ? "Is visible" : "Is not visible");
//g_warning("Username %s", GTK_WIDGET_SENSITIVE(impl->w_username) ? "Is sensitive" : "Is not sensitive");
//g_warning("Widget: %s",gtk_widget_get_name(impl->widget));
impl->w_username = GTK_ENTRY(glade_xml_get_widget(impl->xml, "username"));
g_signal_connect (impl->w_username, "changed", G_CALLBACK (entry_changed), impl);
// gtk_widget_grab_focus (GTK_WIDGET(impl->w_username));
gtk_widget_child_focus (GTK_WIDGET(impl->w_username),GTK_DIR_TAB_FORWARD);
children = gtk_container_get_children (GTK_CONTAINER (impl->widget));
for (i = children; i != NULL; i = g_list_next (i)) {
w = GTK_WIDGET (i->data);
g_warning("Has child: %s",gtk_widget_get_name(w));
}
g_list_free (children);
}
static void
goto_next (GtkWidget *widget,gpointer data)
{
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) data;
g_warning("Goto next!");
if (strcmp(gtk_widget_get_name(widget),"username")==0) {
gtk_widget_grab_focus (GTK_WIDGET(impl->w_password));
} else if (strcmp(gtk_widget_get_name(widget),"password")==0) {
}
}
static gboolean
impl_set_user (GnomeGenericAuthModule *self, const char *user)
{
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data;
gtk_entry_set_text(impl->w_username,user);
return TRUE;
}
static const char *
impl_get_user (GnomeGenericAuthModule *self)
{
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data;
return gtk_entry_get_text(impl->w_username);
}
static gboolean
impl_set_secret (GnomeGenericAuthModule *self, const char *object, const char *secret)
{
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data;
if (strcmp(object,"password")==0) {
gtk_entry_set_text(impl->w_password,secret);
} else {
return FALSE;
}
return TRUE;
}
static GSList *
impl_get_secrets (GnomeGenericAuthModule *self)
{
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data;
GSList *secrets=NULL;
secrets =
g_slist_append(secrets, g_strdup("password"));
secrets =
g_slist_append(secrets, g_strdup(gtk_entry_get_text(impl->w_password)));
return secrets;
}
static const char *
impl_get_display_name (GnomeGenericAuthModule *self)
{
return AUTH_TYPE_DISPLAY_NAME;
}
static const char *
impl_get_auth_type (GnomeGenericAuthModule *self)
{
return AUTH_TYPE;
}
static GtkWidget *
impl_get_widget (GnomeGenericAuthModule *self)
{
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data;
clear_widget (impl);
return impl->widget;
}
static GnomeGenericAuthModule*
impl_get_object (void)
{
char *glade_file;
GnomeGenericAuthModuleImpl *impl;
// GtkWidget *w;
g_warning("get widget");
impl = g_new0 (GnomeGenericAuthModuleImpl, 1);
glade_file = g_strdup_printf ("%s/%s", GLADEDIR, GLADE_FILE);
impl->xml = glade_xml_new (glade_file, NULL, GETTEXT_PACKAGE);
g_free( glade_file );
if (impl->xml != NULL) {
impl->widget = glade_xml_get_widget(impl->xml, GLADE_WIDGET);
/* make the widget reusable */
g_signal_connect (GTK_OBJECT (impl->widget), "delete-event",
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
impl->w_username = GTK_ENTRY(glade_xml_get_widget(impl->xml,"username"));
impl->w_password = GTK_ENTRY(glade_xml_get_widget(impl->xml,"password"));
g_signal_connect (impl->w_username, "activate", G_CALLBACK (goto_next), impl);
g_signal_connect (impl->w_password, "activate", G_CALLBACK (goto_next), impl);
gtk_widget_show_all(impl->widget);
clear_widget (impl);
impl->parent.get_user = impl_get_user;
impl->parent.set_user = impl_set_user;
impl->parent.get_secrets = impl_get_secrets;
impl->parent.set_secret = impl_set_secret;
impl->parent.get_display_name = impl_get_display_name;
impl->parent.get_auth_type = impl_get_auth_type;
impl->parent.get_widget = impl_get_widget;
impl->parent.data = impl;
return &(impl->parent);
} else {
g_free (impl);
return NULL;
}
}
const char *
get_auth_type (void)
{
return AUTH_TYPE;
}
GnomeGenericAuthModule*
gnome_generic_auth_module_factory (void)
{
return impl_get_object();
}
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* gnome-generic-auth-dialog.h - A use a dialog widget with a combo
* selection box to choose a sub-widget
* which in turn then provides appropriate
* widgets for a particular type of
* authentication
Based of gnome-two-password-dialog.[ch]
from the Gnome Library.