diff --git a/src/charon/plugins/nm/gnome/Makefile.am b/src/charon/plugins/nm/gnome/Makefile.am new file mode 100644 index 000000000..24781a5fb --- /dev/null +++ b/src/charon/plugins/nm/gnome/Makefile.am @@ -0,0 +1,23 @@ +AUTOMAKE_OPTIONS = foreign + +SUBDIRS = properties po + +dbusservicedir = $(sysconfdir)/dbus-1/system.d +dbusservice_DATA = nm-strongswan-service.conf + +nmvpnservicedir = $(sysconfdir)/NetworkManager/VPN +nmvpnservice_DATA = nm-strongswan-service.name + +@INTLTOOL_DESKTOP_RULE@ + +nm-strongswan-service.name: $(srcdir)/nm-strongswan-service.name.in + sed -e 's|[@]LIBEXECDIR[@]|$(libexecdir)|g' $< >$@ + +EXTRA_DIST = nm-strongswan-service.name.in \ + $(dbusservice_DATA) \ + intltool-extract.in \ + intltool-merge.in \ + intltool-update.in + +CLEANFILES = $(nmvpnservice_DATA) *~ +DISTCLEANFILES = intltool-extract intltool-merge intltool-update diff --git a/src/charon/plugins/nm/gnome/autogen.sh b/src/charon/plugins/nm/gnome/autogen.sh new file mode 100755 index 000000000..25847e7c3 --- /dev/null +++ b/src/charon/plugins/nm/gnome/autogen.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# Run this to generate all the initial makefiles, etc. + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. +REQUIRED_AUTOMAKE_VERSION=1.7 +PKG_NAME=NetworkManager-strongswan + +which gnome-autogen.sh || { + echo "You need to install gnome-common from the GNOME CVS" + exit 1 +} +USE_GNOME2_MACROS=1 . gnome-autogen.sh + + diff --git a/src/charon/plugins/nm/gnome/config.h.in b/src/charon/plugins/nm/gnome/config.h.in new file mode 100644 index 000000000..2b64591de --- /dev/null +++ b/src/charon/plugins/nm/gnome/config.h.in @@ -0,0 +1,112 @@ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* always defined to indicate that i18n is enabled */ +#undef ENABLE_NLS + +/* Gettext package */ +#undef GETTEXT_PACKAGE + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +#undef HAVE_BIND_TEXTDOMAIN_CODESET + +/* Define to 1 if you have the `dcgettext' function. */ +#undef HAVE_DCGETTEXT + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define if the GNU gettext() function is already present or preinstalled. */ +#undef HAVE_GETTEXT + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define if your file defines LC_MESSAGES. */ +#undef HAVE_LC_MESSAGES + +/* Define to 1 if you have the header file. */ +#undef HAVE_LOCALE_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_PATHS_H + +/* Define to 1 if you have the `select' function. */ +#undef HAVE_SELECT + +/* Define to 1 if you have the `socket' function. */ +#undef HAVE_SOCKET + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYSLOG_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the `uname' function. */ +#undef HAVE_UNAME + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +#undef NO_MINUS_C_MINUS_O + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Version number of package */ +#undef VERSION + +/* Define to `int' if does not define. */ +#undef mode_t + +/* Define to `int' if does not define. */ +#undef pid_t diff --git a/src/charon/plugins/nm/gnome/configure.in b/src/charon/plugins/nm/gnome/configure.in new file mode 100644 index 000000000..61cf46c09 --- /dev/null +++ b/src/charon/plugins/nm/gnome/configure.in @@ -0,0 +1,120 @@ +AC_PREREQ(2.52) + +AC_INIT(NetworkManager-strongswan, 0.7.0, martin@strongswan.org, NetworkManager-strongswan) +AC_CONFIG_AUX_DIR(.) +AM_INIT_AUTOMAKE([subdir-objects]) +AM_MAINTAINER_MODE + +AM_CONFIG_HEADER(config.h) + +dnl +dnl Require programs +dnl +AC_PROG_CC +AM_PROG_CC_C_O +AC_PROG_INSTALL +AC_PROG_LIBTOOL + +dnl +dnl Required headers +dnl +AC_HEADER_STDC +AC_CHECK_HEADERS(fcntl.h paths.h sys/ioctl.h sys/time.h syslog.h unistd.h) + +dnl +dnl Checks for typedefs, structures, and compiler characteristics. +dnl +AC_TYPE_MODE_T +AC_TYPE_PID_T +AC_HEADER_TIME + +dnl +dnl Checks for library functions. +dnl +AC_PROG_GCC_TRADITIONAL +AC_FUNC_MEMCMP +AC_CHECK_FUNCS(select socket uname) + +GETTEXT_PACKAGE=NetworkManager-strongswan +AC_SUBST(GETTEXT_PACKAGE) +AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package]) + +IT_PROG_INTLTOOL([0.35]) +AM_GLIB_GNU_GETTEXT + +PKG_CHECK_MODULES(GTHREAD, gthread-2.0) +AC_SUBST(GTHREAD_CFLAGS) +AC_SUBST(GTHREAD_LIBS) + +PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.30) +AC_SUBST(DBUS_CFLAGS) +AC_SUBST(DBUS_LIBS) + +if test x"$with_gnome" != xno; then + PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.6) + AC_SUBST(GTK_CFLAGS) + AC_SUBST(GTK_LIBS) + + PKG_CHECK_MODULES(GDK_PIXBUF, gdk-pixbuf-2.0) + AC_SUBST(GDK_PIXBUF_CFLAGS) + AC_SUBST(GDK_PIXBUF_LIBS) + + PKG_CHECK_MODULES(GLADE, libglade-2.0) + AC_SUBST(GLADE_CFLAGS) + AC_SUBST(GLADE_LIBS) + + PKG_CHECK_MODULES(LIBGNOMEUI, libgnomeui-2.0) + AC_SUBST(LIBGNOMEUI_CFLAGS) + AC_SUBST(LIBGNOMEUI_LIBS) + + PKG_CHECK_MODULES(GCONF, gconf-2.0) + AC_SUBST(GCONF_CFLAGS) + AC_SUBST(GCONF_LIBS) + + PKG_CHECK_MODULES(GNOMEKEYRING, gnome-keyring-1) + AC_SUBST(GNOMEKEYRING_CFLAGS) + AC_SUBST(GNOMEKEYRING_LIBS) +fi + +PKG_CHECK_MODULES(NM_UTILS, NetworkManager >= 0.7.0 libnm-util libnm_glib libnm_glib_vpn) +AC_SUBST(NM_UTILS_CFLAGS) +AC_SUBST(NM_UTILS_LIBS) + +AC_ARG_ENABLE(more-warnings, +AC_HELP_STRING([--enable-more-warnings], [Maximum compiler warnings]), +set_more_warnings="$enableval",[ +if test -d "$srcdir/{arch}" || test -d "$srcdir/CVS"; then + set_more_warnings=yes +else + set_more_warnings=no +fi +]) +AC_MSG_CHECKING(for more warnings, including -Werror) +if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then + AC_MSG_RESULT(yes) + CFLAGS="-Wall -Werror -std=gnu89 $CFLAGS" + + for option in -Wno-unused -Wno-strict-aliasing -Wno-sign-compare -Wdeclaration-after-statement -Wno-pointer-sign ; do + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $option" + AC_MSG_CHECKING([whether gcc understands $option]) + AC_TRY_COMPILE([], [], + has_option=yes, + has_option=no,) + if test $has_option = no; then + CFLAGS="$SAVE_CFLAGS" + fi + AC_MSG_RESULT($has_option) + unset has_option + unset SAVE_CFLAGS + done + unset option +else + AC_MSG_RESULT(no) +fi + +AC_OUTPUT([ +Makefile +properties/Makefile +po/Makefile.in +]) diff --git a/src/charon/plugins/nm/gnome/nm-strongswan-service.conf b/src/charon/plugins/nm/gnome/nm-strongswan-service.conf new file mode 100644 index 000000000..dccc19af9 --- /dev/null +++ b/src/charon/plugins/nm/gnome/nm-strongswan-service.conf @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/src/charon/plugins/nm/gnome/nm-strongswan-service.name.in b/src/charon/plugins/nm/gnome/nm-strongswan-service.name.in new file mode 100644 index 000000000..1555d489f --- /dev/null +++ b/src/charon/plugins/nm/gnome/nm-strongswan-service.name.in @@ -0,0 +1,8 @@ +[VPN Connection] +name=strongswan +service=org.freedesktop.NetworkManager.strongswan +program=@LIBEXECDIR@/ipsec/charon + +[GNOME] +auth-dialog=nm-strongswan-auth-dialog +properties=libnm-strongswan-properties diff --git a/src/charon/plugins/nm/gnome/po/LINGUAS b/src/charon/plugins/nm/gnome/po/LINGUAS new file mode 100644 index 000000000..d2b08cb95 --- /dev/null +++ b/src/charon/plugins/nm/gnome/po/LINGUAS @@ -0,0 +1 @@ +# please keep this list sorted alphabetically diff --git a/src/charon/plugins/nm/gnome/po/Makefile.in.in b/src/charon/plugins/nm/gnome/po/Makefile.in.in new file mode 100644 index 000000000..6891e8f7d --- /dev/null +++ b/src/charon/plugins/nm/gnome/po/Makefile.in.in @@ -0,0 +1,218 @@ +# Makefile for program source directory in GNU NLS utilities package. +# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper +# Copyright (C) 2004-2008 Rodney Dawes +# +# This file may be copied and used freely without restrictions. It may +# be used in projects which are not available under a GNU Public License, +# but which still want to provide support for the GNU gettext functionality. +# +# - Modified by Owen Taylor to use GETTEXT_PACKAGE +# instead of PACKAGE and to look for po2tbl in ./ not in intl/ +# +# - Modified by jacob berkman to install +# Makefile.in.in and po2tbl.sed.in for use with glib-gettextize +# +# - Modified by Rodney Dawes for use with intltool +# +# We have the following line for use by intltoolize: +# INTLTOOL_MAKEFILE + +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +SHELL = /bin/sh + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +datadir = @datadir@ +datarootdir = @datarootdir@ +libdir = @libdir@ +DATADIRNAME = @DATADIRNAME@ +itlocaledir = $(prefix)/$(DATADIRNAME)/locale +subdir = po +install_sh = @install_sh@ +# Automake >= 1.8 provides @mkdir_p@. +# Until it can be supposed, use the safe fallback: +mkdir_p = $(install_sh) -d + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ + +GMSGFMT = @GMSGFMT@ +MSGFMT = @MSGFMT@ +XGETTEXT = @XGETTEXT@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +MSGMERGE = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --dist +GENPOT = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --pot + +ALL_LINGUAS = @ALL_LINGUAS@ + +PO_LINGUAS=$(shell if test -r $(srcdir)/LINGUAS; then grep -v "^\#" $(srcdir)/LINGUAS; fi) + +USER_LINGUAS=$(shell if test -n "$(LINGUAS)"; then LLINGUAS="$(LINGUAS)"; ALINGUAS="$(ALL_LINGUAS)"; for lang in $$LLINGUAS; do if test -n "`grep ^$$lang$$ $(srcdir)/LINGUAS`" -o -n "`echo $$ALINGUAS|grep ' ?$$lang ?'`"; then printf "$$lang "; fi; done; fi) + +USE_LINGUAS=$(shell if test -n "$(USER_LINGUAS)"; then LLINGUAS="$(USER_LINGUAS)"; else if test -n "$(PO_LINGUAS)"; then LLINGUAS="$(PO_LINGUAS)"; else LLINGUAS="$(ALL_LINGUAS)"; fi; fi; for lang in $$LLINGUAS; do printf "$$lang "; done) + +POFILES=$(shell LINGUAS="$(USE_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.po "; done) + +DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(POFILES) +EXTRA_DISTFILES = POTFILES.skip Makevars LINGUAS + +POTFILES = \ +# This comment gets stripped out + +CATALOGS=$(shell LINGUAS="$(USE_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.gmo "; done) + +.SUFFIXES: +.SUFFIXES: .po .pox .gmo .mo .msg .cat + +.po.pox: + $(MAKE) $(GETTEXT_PACKAGE).pot + $(MSGMERGE) $< $(GETTEXT_PACKAGE).pot -o $*.pox + +.po.mo: + $(MSGFMT) -o $@ $< + +.po.gmo: + file=`echo $* | sed 's,.*/,,'`.gmo \ + && rm -f $$file && $(GMSGFMT) -o $$file $< + +.po.cat: + sed -f ../intl/po2msg.sed < $< > $*.msg \ + && rm -f $@ && gencat $@ $*.msg + + +all: all-@USE_NLS@ + +all-yes: $(CATALOGS) +all-no: + +$(GETTEXT_PACKAGE).pot: $(POTFILES) + $(GENPOT) + +install: install-data +install-data: install-data-@USE_NLS@ +install-data-no: all +install-data-yes: all + $(mkdir_p) $(DESTDIR)$(itlocaledir) + linguas="$(USE_LINGUAS)"; \ + for lang in $$linguas; do \ + dir=$(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES; \ + $(mkdir_p) $$dir; \ + if test -r $$lang.gmo; then \ + $(INSTALL_DATA) $$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \ + echo "installing $$lang.gmo as $$dir/$(GETTEXT_PACKAGE).mo"; \ + else \ + $(INSTALL_DATA) $(srcdir)/$$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \ + echo "installing $(srcdir)/$$lang.gmo as" \ + "$$dir/$(GETTEXT_PACKAGE).mo"; \ + fi; \ + if test -r $$lang.gmo.m; then \ + $(INSTALL_DATA) $$lang.gmo.m $$dir/$(GETTEXT_PACKAGE).mo.m; \ + echo "installing $$lang.gmo.m as $$dir/$(GETTEXT_PACKAGE).mo.m"; \ + else \ + if test -r $(srcdir)/$$lang.gmo.m ; then \ + $(INSTALL_DATA) $(srcdir)/$$lang.gmo.m \ + $$dir/$(GETTEXT_PACKAGE).mo.m; \ + echo "installing $(srcdir)/$$lang.gmo.m as" \ + "$$dir/$(GETTEXT_PACKAGE).mo.m"; \ + else \ + true; \ + fi; \ + fi; \ + done + +# Empty stubs to satisfy archaic automake needs +dvi info tags TAGS ID: + +# Define this as empty until I found a useful application. +install-exec installcheck: + +uninstall: + linguas="$(USE_LINGUAS)"; \ + for lang in $$linguas; do \ + rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo; \ + rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo.m; \ + done + +check: all $(GETTEXT_PACKAGE).pot + rm -f missing notexist + srcdir=$(srcdir) $(INTLTOOL_UPDATE) -m + if [ -r missing -o -r notexist ]; then \ + exit 1; \ + fi + +mostlyclean: + rm -f *.pox $(GETTEXT_PACKAGE).pot *.old.po cat-id-tbl.tmp + rm -f .intltool-merge-cache + +clean: mostlyclean + +distclean: clean + rm -f Makefile Makefile.in POTFILES stamp-it + rm -f *.mo *.msg *.cat *.cat.m *.gmo + +maintainer-clean: distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + rm -f Makefile.in.in + +distdir = ../$(PACKAGE)-$(VERSION)/$(subdir) +dist distdir: $(DISTFILES) + dists="$(DISTFILES)"; \ + extra_dists="$(EXTRA_DISTFILES)"; \ + for file in $$extra_dists; do \ + test -f $(srcdir)/$$file && dists="$$dists $(srcdir)/$$file"; \ + done; \ + for file in $$dists; do \ + test -f $$file || file="$(srcdir)/$$file"; \ + ln $$file $(distdir) 2> /dev/null \ + || cp -p $$file $(distdir); \ + done + +update-po: Makefile + $(MAKE) $(GETTEXT_PACKAGE).pot + tmpdir=`pwd`; \ + linguas="$(USE_LINGUAS)"; \ + for lang in $$linguas; do \ + echo "$$lang:"; \ + result="`$(MSGMERGE) -o $$tmpdir/$$lang.new.po $$lang`"; \ + if $$result; then \ + if cmp $(srcdir)/$$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ + rm -f $$tmpdir/$$lang.new.po; \ + else \ + if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ + :; \ + else \ + echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ + rm -f $$tmpdir/$$lang.new.po; \ + exit 1; \ + fi; \ + fi; \ + else \ + echo "msgmerge for $$lang.gmo failed!"; \ + rm -f $$tmpdir/$$lang.new.po; \ + fi; \ + done + +Makefile POTFILES: stamp-it + @if test ! -f $@; then \ + rm -f stamp-it; \ + $(MAKE) stamp-it; \ + fi + +stamp-it: Makefile.in.in $(top_builddir)/config.status POTFILES.in + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/Makefile.in CONFIG_HEADERS= CONFIG_LINKS= \ + $(SHELL) ./config.status + +# Tell versions [3.59,3.63) of GNU make not to export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/charon/plugins/nm/gnome/po/POTFILES.in b/src/charon/plugins/nm/gnome/po/POTFILES.in new file mode 100644 index 000000000..b6cc420a9 --- /dev/null +++ b/src/charon/plugins/nm/gnome/po/POTFILES.in @@ -0,0 +1,6 @@ +# List of source files containing translatable strings. +# Please keep this file sorted alphabetically. +properties/nm-strongswan.c +properties/nm-strongswan-dialog.glade + + diff --git a/src/charon/plugins/nm/gnome/properties/Makefile.am b/src/charon/plugins/nm/gnome/properties/Makefile.am new file mode 100644 index 000000000..acbab6357 --- /dev/null +++ b/src/charon/plugins/nm/gnome/properties/Makefile.am @@ -0,0 +1,38 @@ +plugindir = $(libdir)/NetworkManager +plugin_LTLIBRARIES = libnm-strongswan-properties.la + +libnm_strongswan_properties_la_SOURCES = \ + nm-strongswan.c \ + nm-strongswan.h + +gladedir = $(datadir)/gnome-vpn-properties/strongswan +glade_DATA = nm-strongswan-dialog.glade + +libnm_strongswan_properties_la_CFLAGS = \ + $(GLADE_CFLAGS) \ + $(GTK_CFLAGS) \ + $(GCONF_CFLAGS) \ + $(LIBGNOMEUI_CFLAGS) \ + $(NM_UTILS_CFLAGS) \ + -DICONDIR=\""$(datadir)/pixmaps"\" \ + -DGLADEDIR=\""$(gladedir)"\" \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGNOME_DISABLE_DEPRECATED \ + -DGNOMELOCALEDIR=\"$(datadir)/locale\" \ + -DVERSION=\"$(VERSION)\" + +libnm_strongswan_properties_la_LIBADD = \ + $(GLADE_LIBS) \ + $(GTK_LIBS) \ + $(GCONF_LIBS) \ + $(LIBGNOMEUI_LIBS) \ + $(NM_UTILS_LIBS) + +libnm_strongswan_properties_la_LDFLAGS = \ + -avoid-version + +CLEANFILES = *.bak *.gladep *~ + +EXTRA_DIST = \ + $(glade_DATA) diff --git a/src/charon/plugins/nm/gnome/properties/nm-strongswan-dialog.glade b/src/charon/plugins/nm/gnome/properties/nm-strongswan-dialog.glade new file mode 100644 index 000000000..42c06c8bc --- /dev/null +++ b/src/charon/plugins/nm/gnome/properties/nm-strongswan-dialog.glade @@ -0,0 +1,287 @@ + + + + + + window1 + + + True + 12 + 16 + + + True + 6 + + + True + 0 + <b>Gateway</b> + True + + + False + False + + + + + True + 12 + + + True + 2 + 2 + 6 + 6 + + + True + 0 + _Address: + True + address-entry + + + GTK_FILL + + + + + + True + True + True + An IP address or hostname the Gateway can be contacted. + + + 1 + 2 + + + + + + True + 0 + _Certificate: + True + certificate-button + + + 1 + 2 + GTK_FILL + + + + + + True + True + True + True + A trusted certificate to use to authenticate the Gateway. + (none) + 0 + + + 1 + 2 + 1 + 2 + + + + + + + + 1 + + + + + False + + + + + True + 6 + + + True + 0 + <b>Authentication</b> + True + + + False + False + + + + + True + 12 + + + True + 2 + 2 + 6 + 6 + + + True + True + True + The username (identity) to use for authentication against the gateway. + + + 1 + 2 + + + + + + True + 0 + _Method: + True + method-combo + + + 1 + 2 + GTK_FILL + + + + + + True + False + True + Authentication Method to use for authentication against the Gateway. + + + + 1 + 2 + 1 + 2 + + + + + True + 0 + _Username: + True + user-entry + + + GTK_FILL + + + + + + + + 1 + + + + + False + 1 + + + + + True + 6 + + + True + 0 + <b>Options</b> + True + + + False + False + + + + + True + 12 + + + True + + + True + True + True + The Gateway may provide addresses from a pool to use for communication in the Gateways network. Check to request such an address. + Request an _inner IP address + True + 0 + True + + + + + True + True + True + Some firewalls block ESP traffic. Enforcing UDP capsulation even if no NAT situation is detected might help in such cases. + En_force UDP encapsulation + True + 0 + True + + + 1 + + + + + True + True + True + IPComp compresses raw IP packets before they get encrypted. This saves some bandwith, but uses more processing power. + Use IP c_ompression + True + 0 + True + + + 2 + + + + + + + 1 + + + + + False + 2 + + + + + + diff --git a/src/charon/plugins/nm/gnome/properties/nm-strongswan.c b/src/charon/plugins/nm/gnome/properties/nm-strongswan.c new file mode 100644 index 000000000..272f79a3c --- /dev/null +++ b/src/charon/plugins/nm/gnome/properties/nm-strongswan.c @@ -0,0 +1,484 @@ +/* + * Copyright (C) 2008 Martin Willi + * Hochschule fuer Technik Rapperswil + * Copyright (C) 2005 David Zeuthen + * Copyright (C) 2005-2008 Dan Williams + * + * Based on NetworkManager's vpnc plugin + * + * 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$ + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include + +#define NM_VPN_API_SUBJECT_TO_CHANGE + +#include +#include +#include +#include +#include + +#include "nm-strongswan.h" + +#define STRONGSWAN_PLUGIN_NAME _("IPsec/IKEv2 (strongswan)") +#define STRONGSWAN_PLUGIN_DESC _("IPsec with the IKEv2 key exchange protocol.") +#define STRONGSWAN_PLUGIN_SERVICE "org.freedesktop.NetworkManager.strongswan" +#define NM_DBUS_SERVICE_STRONGSWAN "org.freedesktop.NetworkManager.strongswan" + +/************** plugin class **************/ + +static void strongswan_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class); + +G_DEFINE_TYPE_EXTENDED (StrongswanPluginUi, strongswan_plugin_ui, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_INTERFACE, + strongswan_plugin_ui_interface_init)) + +#define STRONGSWAN_PLUGIN_UI_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), STRONGSWAN_TYPE_PLUGIN_UI, StrongswanPluginUiPrivate)) + +typedef struct { +} StrongswanPluginUiPrivate; + + +/************** UI widget class **************/ + +static void strongswan_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class); + +G_DEFINE_TYPE_EXTENDED (StrongswanPluginUiWidget, strongswan_plugin_ui_widget, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE, + strongswan_plugin_ui_widget_interface_init)) + +#define STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), STRONGSWAN_TYPE_PLUGIN_UI_WIDGET, StrongswanPluginUiWidgetPrivate)) + +typedef struct { + GladeXML *xml; + GtkWidget *widget; +} StrongswanPluginUiWidgetPrivate; + + +#define STRONGSWAN_PLUGIN_UI_ERROR strongswan_plugin_ui_error_quark () + +static GQuark +strongswan_plugin_ui_error_quark (void) +{ + static GQuark error_quark = 0; + + if (G_UNLIKELY (error_quark == 0)) + error_quark = g_quark_from_static_string ("strongswan-plugin-ui-error-quark"); + + return error_quark; +} + +#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } + +GType +strongswan_plugin_ui_error_get_type (void) +{ + static GType etype = 0; + + if (etype == 0) { + static const GEnumValue values[] = { + /* Unknown error. */ + ENUM_ENTRY (STRONGSWAN_PLUGIN_UI_ERROR_UNKNOWN, "UnknownError"), + /* The specified property was invalid. */ + ENUM_ENTRY (STRONGSWAN_PLUGIN_UI_ERROR_INVALID_PROPERTY, "InvalidProperty"), + /* The specified property was missing and is required. */ + ENUM_ENTRY (STRONGSWAN_PLUGIN_UI_ERROR_MISSING_PROPERTY, "MissingProperty"), + { 0, 0, 0 } + }; + etype = g_enum_register_static ("StrongswanPluginUiError", values); + } + return etype; +} + +static gboolean +check_validity (StrongswanPluginUiWidget *self, GError **error) +{ + StrongswanPluginUiWidgetPrivate *priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + GtkWidget *widget; + char *str; + + widget = glade_xml_get_widget (priv->xml, "address-entry"); + str = (char *) gtk_entry_get_text (GTK_ENTRY (widget)); + if (!str || !strlen (str)) { + g_set_error (error, + STRONGSWAN_PLUGIN_UI_ERROR, + STRONGSWAN_PLUGIN_UI_ERROR_INVALID_PROPERTY, + "address"); + return FALSE; + } + + widget = glade_xml_get_widget (priv->xml, "user-entry"); + str = (char *) gtk_entry_get_text (GTK_ENTRY (widget)); + if (!str || !strlen (str)) { + g_set_error (error, + STRONGSWAN_PLUGIN_UI_ERROR, + STRONGSWAN_PLUGIN_UI_ERROR_INVALID_PROPERTY, + "user"); + return FALSE; + } + + return TRUE; +} + +static void +stuff_changed_cb (GtkWidget *widget, gpointer user_data) +{ + g_signal_emit_by_name (STRONGSWAN_PLUGIN_UI_WIDGET (user_data), "changed"); +} + +static gboolean +init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError **error) +{ + StrongswanPluginUiWidgetPrivate *priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + NMSettingVPNProperties *s_vpn_props; + GtkWidget *widget; + GValue *value; + gboolean active; + + s_vpn_props = (NMSettingVPNProperties *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN_PROPERTIES); + + + widget = glade_xml_get_widget (priv->xml, "address-entry"); + if (!widget) + return FALSE; + if (s_vpn_props) { + value = g_hash_table_lookup (s_vpn_props->data, "address"); + if (value && G_VALUE_HOLDS_STRING (value)) + gtk_entry_set_text (GTK_ENTRY (widget), g_value_get_string (value)); + } + g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self); + + widget = glade_xml_get_widget (priv->xml, "user-entry"); + if (!widget) + return FALSE; + if (s_vpn_props) { + value = g_hash_table_lookup (s_vpn_props->data, "user"); + if (value && G_VALUE_HOLDS_STRING (value)) + gtk_entry_set_text (GTK_ENTRY (widget), g_value_get_string (value)); + } + g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self); + + widget = glade_xml_get_widget (priv->xml, "virtual-check"); + if (!widget) + return FALSE; + active = TRUE; + if (s_vpn_props) { + value = g_hash_table_lookup (s_vpn_props->data, "virtual"); + if (value && G_VALUE_HOLDS_BOOLEAN (value)) + active = g_value_get_boolean (value); + } + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), active); + g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (stuff_changed_cb), self); + + widget = glade_xml_get_widget (priv->xml, "encap-check"); + if (!widget) + return FALSE; + active = TRUE; + if (s_vpn_props) { + value = g_hash_table_lookup (s_vpn_props->data, "encap"); + if (value && G_VALUE_HOLDS_BOOLEAN (value)) + active = g_value_get_boolean (value); + } + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), active); + g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (stuff_changed_cb), self); + + widget = glade_xml_get_widget (priv->xml, "ipcomp-check"); + if (!widget) + return FALSE; + active = FALSE; + if (s_vpn_props) { + value = g_hash_table_lookup (s_vpn_props->data, "ipcomp"); + if (value && G_VALUE_HOLDS_BOOLEAN (value)) + active = g_value_get_boolean (value); + } + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), active); + g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (stuff_changed_cb), self); + + return TRUE; +} + +static GObject * +get_widget (NMVpnPluginUiWidgetInterface *iface) +{ + StrongswanPluginUiWidget *self = STRONGSWAN_PLUGIN_UI_WIDGET (iface); + StrongswanPluginUiWidgetPrivate *priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + + return G_OBJECT (priv->widget); +} + +static GValue * +str_to_gvalue (const char *str) +{ + GValue *value; + + value = g_slice_new0 (GValue); + g_value_init (value, G_TYPE_STRING); + g_value_set_string (value, str); + + return value; +} + +static GValue * +bool_to_gvalue (gboolean b) +{ + GValue *value; + + value = g_slice_new0 (GValue); + g_value_init (value, G_TYPE_BOOLEAN); + g_value_set_boolean (value, b); + + return value; +} + +static GValue * +int_to_gvalue (gint i) +{ + GValue *value; + + value = g_slice_new0 (GValue); + g_value_init (value, G_TYPE_INT); + g_value_set_int (value, i); + + return value; +} + +static gboolean +update_connection (NMVpnPluginUiWidgetInterface *iface, + NMConnection *connection, + GError **error) +{ + StrongswanPluginUiWidget *self = STRONGSWAN_PLUGIN_UI_WIDGET (iface); + StrongswanPluginUiWidgetPrivate *priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + NMSettingVPN *s_vpn; + NMSettingVPNProperties *s_vpn_props; + GtkWidget *widget; + GValue *value; + gboolean active; + char *str; + GtkTreeModel *model; + GtkTreeIter iter; + + if (!check_validity (self, error)) + return FALSE; + + s_vpn = NM_SETTING_VPN (nm_setting_vpn_new ()); + s_vpn->service_type = g_strdup (NM_DBUS_SERVICE_STRONGSWAN); + nm_connection_add_setting (connection, NM_SETTING (s_vpn)); + + s_vpn_props = NM_SETTING_VPN_PROPERTIES (nm_setting_vpn_properties_new ()); + + widget = glade_xml_get_widget (priv->xml, "address-entry"); + str = (char *) gtk_entry_get_text (GTK_ENTRY (widget)); + if (str && strlen (str)) { + g_hash_table_insert (s_vpn_props->data, + g_strdup ("address"), + str_to_gvalue (str)); + } + + widget = glade_xml_get_widget (priv->xml, "user-entry"); + str = (char *) gtk_entry_get_text (GTK_ENTRY (widget)); + if (str && strlen (str)) { + g_hash_table_insert (s_vpn_props->data, + g_strdup ("user"), + str_to_gvalue (str)); + } + + widget = glade_xml_get_widget (priv->xml, "virtual-check"); + active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + g_hash_table_insert (s_vpn_props->data, g_strdup ("virtual"), + bool_to_gvalue(active)); + + widget = glade_xml_get_widget (priv->xml, "encap-check"); + active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + g_hash_table_insert (s_vpn_props->data, g_strdup ("encap"), + bool_to_gvalue(active)); + + widget = glade_xml_get_widget (priv->xml, "ipcomp-check"); + active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + g_hash_table_insert (s_vpn_props->data, g_strdup ("ipcomp"), + bool_to_gvalue(active)); + + nm_connection_add_setting (connection, NM_SETTING (s_vpn_props)); + return TRUE; +} + +static NMVpnPluginUiWidgetInterface * +nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) +{ + NMVpnPluginUiWidgetInterface *object; + StrongswanPluginUiWidgetPrivate *priv; + char *glade_file; + + if (error) + g_return_val_if_fail (*error == NULL, NULL); + + object = NM_VPN_PLUGIN_UI_WIDGET_INTERFACE (g_object_new (STRONGSWAN_TYPE_PLUGIN_UI_WIDGET, NULL)); + if (!object) { + g_set_error (error, STRONGSWAN_PLUGIN_UI_ERROR, 0, "could not create strongswan object"); + return NULL; + } + + priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (object); + + glade_file = g_strdup_printf ("%s/%s", GLADEDIR, "nm-strongswan-dialog.glade"); + priv->xml = glade_xml_new (glade_file, "strongswan-vbox", GETTEXT_PACKAGE); + if (priv->xml == NULL) { + g_set_error (error, STRONGSWAN_PLUGIN_UI_ERROR, 0, + "could not load required resources at %s", glade_file); + g_free (glade_file); + g_object_unref (object); + return NULL; + } + g_free (glade_file); + + priv->widget = glade_xml_get_widget (priv->xml, "strongswan-vbox"); + if (!priv->widget) { + g_set_error (error, STRONGSWAN_PLUGIN_UI_ERROR, 0, "could not load UI widget"); + g_object_unref (object); + return NULL; + } + g_object_ref_sink (priv->widget); + + if (!init_plugin_ui (STRONGSWAN_PLUGIN_UI_WIDGET (object), connection, error)) { + g_object_unref (object); + return NULL; + } + + return object; +} + +static void +dispose (GObject *object) +{ + StrongswanPluginUiWidget *plugin = STRONGSWAN_PLUGIN_UI_WIDGET (object); + StrongswanPluginUiWidgetPrivate *priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (plugin); + + if (priv->widget) + g_object_unref (priv->widget); + + if (priv->xml) + g_object_unref (priv->xml); + + G_OBJECT_CLASS (strongswan_plugin_ui_widget_parent_class)->dispose (object); +} + +static void +strongswan_plugin_ui_widget_class_init (StrongswanPluginUiWidgetClass *req_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (req_class); + + g_type_class_add_private (req_class, sizeof (StrongswanPluginUiWidgetPrivate)); + + object_class->dispose = dispose; +} + +static void +strongswan_plugin_ui_widget_init (StrongswanPluginUiWidget *plugin) +{ +} + +static void +strongswan_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class) +{ + /* interface implementation */ + iface_class->get_widget = get_widget; + iface_class->update_connection = update_connection; +} + +static guint32 +get_capabilities (NMVpnPluginUiInterface *iface) +{ + return 0; +} + +static NMVpnPluginUiWidgetInterface * +ui_factory (NMVpnPluginUiInterface *iface, NMConnection *connection, GError **error) +{ + return nm_vpn_plugin_ui_widget_interface_new (connection, error); +} + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + switch (prop_id) { + case NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME: + g_value_set_string (value, STRONGSWAN_PLUGIN_NAME); + break; + case NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC: + g_value_set_string (value, STRONGSWAN_PLUGIN_DESC); + break; + case NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE: + g_value_set_string (value, STRONGSWAN_PLUGIN_SERVICE); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +strongswan_plugin_ui_class_init (StrongswanPluginUiClass *req_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (req_class); + + g_type_class_add_private (req_class, sizeof (StrongswanPluginUiPrivate)); + + object_class->get_property = get_property; + + g_object_class_override_property (object_class, + NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME, + NM_VPN_PLUGIN_UI_INTERFACE_NAME); + + g_object_class_override_property (object_class, + NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC, + NM_VPN_PLUGIN_UI_INTERFACE_DESC); + + g_object_class_override_property (object_class, + NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE, + NM_VPN_PLUGIN_UI_INTERFACE_SERVICE); +} + +static void +strongswan_plugin_ui_init (StrongswanPluginUi *plugin) +{ +} + +static void +strongswan_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class) +{ + /* interface implementation */ + iface_class->ui_factory = ui_factory; + iface_class->get_capabilities = get_capabilities; +} + + +G_MODULE_EXPORT NMVpnPluginUiInterface * +nm_vpn_plugin_ui_factory (GError **error) +{ + if (error) + g_return_val_if_fail (*error == NULL, NULL); + + return NM_VPN_PLUGIN_UI_INTERFACE (g_object_new (STRONGSWAN_TYPE_PLUGIN_UI, NULL)); +} + diff --git a/src/charon/plugins/nm/gnome/properties/nm-strongswan.h b/src/charon/plugins/nm/gnome/properties/nm-strongswan.h new file mode 100644 index 000000000..793c3d97a --- /dev/null +++ b/src/charon/plugins/nm/gnome/properties/nm-strongswan.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2008 Martin Willi + * Hochschule fuer Technik Rapperswil + * Copyright (C) 2008 Dan Williams + * + * Based on NetworkManager's vpnc plugin + * + * 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$ + */ + +#ifndef _NM_STRONGSWAN_H_ +#define _NM_STRONGSWAN_H_ + +#include + +typedef enum +{ + STRONGSWAN_PLUGIN_UI_ERROR_UNKNOWN = 0, + STRONGSWAN_PLUGIN_UI_ERROR_INVALID_PROPERTY, + STRONGSWAN_PLUGIN_UI_ERROR_MISSING_PROPERTY +} StrongswanPluginUiError; + +#define STRONGSWAN_TYPE_PLUGIN_UI_ERROR (strongswan_plugin_ui_error_get_type ()) +GType strongswan_plugin_ui_error_get_type (void); + +#define STRONGSWAN_TYPE_PLUGIN_UI (strongswan_plugin_ui_get_type ()) +#define STRONGSWAN_PLUGIN_UI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), STRONGSWAN_TYPE_PLUGIN_UI, StrongswanPluginUi)) +#define STRONGSWAN_PLUGIN_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), STRONGSWAN_TYPE_PLUGIN_UI, StrongswanPluginUiClass)) +#define STRONGSWAN_IS_PLUGIN_UI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), STRONGSWAN_TYPE_PLUGIN_UI)) +#define STRONGSWAN_IS_PLUGIN_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), STRONGSWAN_TYPE_PLUGIN_UI)) +#define STRONGSWAN_PLUGIN_UI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), STRONGSWAN_TYPE_PLUGIN_UI, StrongswanPluginUiClass)) + +typedef struct _StrongswanPluginUi StrongswanPluginUi; +typedef struct _StrongswanPluginUiClass StrongswanPluginUiClass; + +struct _StrongswanPluginUi { + GObject parent; +}; + +struct _StrongswanPluginUiClass { + GObjectClass parent; +}; + +GType strongswan_plugin_ui_get_type (void); + + +#define STRONGSWAN_TYPE_PLUGIN_UI_WIDGET (strongswan_plugin_ui_widget_get_type ()) +#define STRONGSWAN_PLUGIN_UI_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), STRONGSWAN_TYPE_PLUGIN_UI_WIDGET, StrongswanPluginUiWidget)) +#define STRONGSWAN_PLUGIN_UI_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), STRONGSWAN_TYPE_PLUGIN_UI_WIDGET, StrongswanPluginUiWidgetClass)) +#define STRONGSWAN_IS_PLUGIN_UI_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), STRONGSWAN_TYPE_PLUGIN_UI_WIDGET)) +#define STRONGSWAN_IS_PLUGIN_UI_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), STRONGSWAN_TYPE_PLUGIN_UI_WIDGET)) +#define STRONGSWAN_PLUGIN_UI_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), STRONGSWAN_TYPE_PLUGIN_UI_WIDGET, StrongswanPluginUiWidgetClass)) + +typedef struct _StrongswanPluginUiWidget StrongswanPluginUiWidget; +typedef struct _StrongswanPluginUiWidgetClass StrongswanPluginUiWidgetClass; + +struct _StrongswanPluginUiWidget { + GObject parent; +}; + +struct _StrongswanPluginUiWidgetClass { + GObjectClass parent; +}; + +GType strongswan_plugin_ui_widget_get_type (void); + +#endif /* _NM_STRONGSWAN_H_ */ +