diff --git a/src/frontends/gnome/.gitignore b/src/frontends/gnome/.gitignore index 386bd1eb2..82fd10c9e 100644 --- a/src/frontends/gnome/.gitignore +++ b/src/frontends/gnome/.gitignore @@ -11,3 +11,7 @@ config.guess.cdbs-orig config.sub.cdbs-orig NetworkManager-strongswan.metainfo.xml NetworkManager-strongswan.pot +properties/nm-strongswan-resources.c +properties/nm-strongswan-resources.h +properties/gtk4/nm-strongswan-dialog.ui +properties/gtk4/nm-strongswan-resources.c diff --git a/src/frontends/gnome/Makefile.am b/src/frontends/gnome/Makefile.am index 646d913a2..3dd41a3bc 100644 --- a/src/frontends/gnome/Makefile.am +++ b/src/frontends/gnome/Makefile.am @@ -11,23 +11,6 @@ metainfo_DATA = $(metainfo_in_files:.xml.in=.xml) metainfo_in_files = NetworkManager-strongswan.metainfo.xml.in @INTLTOOL_XML_RULE@ -if WITH_LIBNM_GLIB -# Install a file with full path to plugins for an old gnome-shell -# https://bugzilla.gnome.org/show_bug.cgi?id=693590 -install-data-hook: - mkdir -p $(DESTDIR)$(sysconfdir)/NetworkManager/VPN - sed -e "1s|^|# This file is obsoleted by a file in $(nmvpnservicedir)\n\n|" \ - -e 's|[@]NM_LIBEXECDIR[@]|$(nm_libexecdir)|g' \ - -e 's|[@]NM_PLUGINDIR[@]|$(nm_plugindir)|g' \ - -e 's|[@]NM_PLUGINDIR_ABS[@]|$(nm_plugindir)|g' \ - -e 's|[@]CHARON[@]|$(charon)|' \ - <$(srcdir)/nm-strongswan-service.name.in \ - >$(DESTDIR)$(sysconfdir)/NetworkManager/VPN/nm-strongswan-service.name - -uninstall-hook: - rm -f $(DESTDIR)$(sysconfdir)/NetworkManager/VPN/nm-strongswan-service.name -endif - nm-strongswan-service.name: $(srcdir)/nm-strongswan-service.name.in $(AM_V_GEN) \ sed -e 's|[@]NM_LIBEXECDIR[@]|$(nm_libexecdir)|' \ diff --git a/src/frontends/gnome/NEWS b/src/frontends/gnome/NEWS index f5e48ce39..18b60628c 100644 --- a/src/frontends/gnome/NEWS +++ b/src/frontends/gnome/NEWS @@ -1,3 +1,9 @@ +NetworkManager-strongswan-1.6.0 +------------------------------- + +- Support for GTK 4 +- Removed libnm-glib compatibility + NetworkManager-strongswan-1.5.2 ------------------------------- diff --git a/src/frontends/gnome/configure.ac b/src/frontends/gnome/configure.ac index f92049bf5..c374194f7 100644 --- a/src/frontends/gnome/configure.ac +++ b/src/frontends/gnome/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ(2.52) -AC_INIT(NetworkManager-strongswan, 1.5.2, info@strongswan.org, NetworkManager-strongswan) +AC_INIT(NetworkManager-strongswan, 1.6.0, info@strongswan.org, NetworkManager-strongswan) AM_INIT_AUTOMAKE([subdir-objects]) AM_MAINTAINER_MODE @@ -15,6 +15,7 @@ AM_PROG_CC_C_O AC_PROG_INSTALL AC_PROG_LIBTOOL PKG_PROG_PKG_CONFIG +AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources) dnl dnl Required headers @@ -36,6 +37,9 @@ AC_PROG_GCC_TRADITIONAL AC_FUNC_MEMCMP AC_CHECK_FUNCS(select socket uname) +AC_SEARCH_LIBS([dlopen], [dl dld], [], [ac_cv_search_dlopen=]) +AC_SUBST([DL_LIBS], "$ac_cv_search_dlopen") + GETTEXT_PACKAGE=NetworkManager-strongswan AC_SUBST(GETTEXT_PACKAGE) AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package]) @@ -67,35 +71,28 @@ AC_ARG_ENABLE( AS_HELP_STRING([--enable-nm-absolute-paths],[use absolute paths for NM plugins in the .name file]) ) AC_ARG_WITH( - [libnm-glib], - AS_HELP_STRING([--without-libnm-glib], [build NetworkManager-strongswan without libnm-glib compatibility]), - [with_libnm_glib=no], - [with_libnm_glib=yes] + [gtk4], + AS_HELP_STRING([--with-gtk4], [build NetworkManager-strongswan with libnma-gtk4 support]), + [], [with_gtk4=no] ) -AM_CONDITIONAL(WITH_LIBNM_GLIB, test "$with_libnm_glib" != no) +AM_CONDITIONAL(WITH_GTK4, test "$with_gtk4" != no) PKG_CHECK_MODULES(LIBNM, libnm >= 1.1.0) LIBNM_CFLAGS="$LIBNM_CFLAGS -DNM_VERSION_MIN_REQUIRED=NM_VERSION_1_2" LIBNM_CFLAGS="$LIBNM_CFLAGS -DNM_VERSION_MAX_ALLOWED=NM_VERSION_1_2" PKG_CHECK_MODULES(LIBNMA, libnma >= 1.1.0) -if test x"$with_libnm_glib" != xno; then - PKG_CHECK_MODULES(LIBNM_GLIB, NetworkManager >= 1.1.0 libnm-util libnm-glib libnm-glib-vpn) - PKG_CHECK_MODULES(LIBNM_GTK, libnm-gtk >= 1.1.0) - if test -z "$nm_libexecdir"; then - nm_libexecdir=$($PKG_CONFIG --variable=libgnome_serverdir NetworkManager) - fi - if test -z "$nm_plugindir"; then - nm_plugindir=$($PKG_CONFIG --variable=plugindir NetworkManager) - fi -else - if test -z "$nm_libexecdir"; then - nm_libexecdir=$($PKG_CONFIG --variable=exec_prefix libnm)/lib/NetworkManager - fi - if test -z "$nm_plugindir"; then - nm_plugindir=$($PKG_CONFIG --variable=libdir libnm)/NetworkManager - fi +if test x"$with_gtk4" != xno; then + PKG_CHECK_MODULES(GTK4, gtk4 >= 4.0) + PKG_CHECK_MODULES(LIBNMA_GTK4, libnma-gtk4 >= 1.8.33) +fi + +if test -z "$nm_libexecdir"; then + nm_libexecdir=$($PKG_CONFIG --variable=exec_prefix libnm)/lib/NetworkManager +fi +if test -z "$nm_plugindir"; then + nm_plugindir=$($PKG_CONFIG --variable=libdir libnm)/NetworkManager fi AC_SUBST(nm_libexecdir) diff --git a/src/frontends/gnome/nm-strongswan-service.name.in b/src/frontends/gnome/nm-strongswan-service.name.in index f52eec26d..373262a41 100644 --- a/src/frontends/gnome/nm-strongswan-service.name.in +++ b/src/frontends/gnome/nm-strongswan-service.name.in @@ -8,5 +8,4 @@ plugin=@NM_PLUGINDIR@/libnm-vpn-plugin-strongswan.so [GNOME] auth-dialog=@NM_LIBEXECDIR@/nm-strongswan-auth-dialog -properties=@NM_PLUGINDIR_ABS@/libnm-strongswan-properties supports-external-ui-mode=true diff --git a/src/frontends/gnome/po/POTFILES.in b/src/frontends/gnome/po/POTFILES.in index 1b05c101e..f35860687 100644 --- a/src/frontends/gnome/po/POTFILES.in +++ b/src/frontends/gnome/po/POTFILES.in @@ -1,5 +1,6 @@ # List of source files containing translatable strings. # Please keep this file sorted alphabetically. +properties/nm-strongswan-plugin.c properties/nm-strongswan.c [type: gettext/glade]properties/nm-strongswan-dialog.ui auth-dialog/main.c diff --git a/src/frontends/gnome/po/POTFILES.skip b/src/frontends/gnome/po/POTFILES.skip new file mode 100644 index 000000000..ba7da4ed6 --- /dev/null +++ b/src/frontends/gnome/po/POTFILES.skip @@ -0,0 +1 @@ +properties/gtk4/nm-strongswan-dialog.ui diff --git a/src/frontends/gnome/po/de.po b/src/frontends/gnome/po/de.po index 7ab216fcc..fbb8da01a 100644 --- a/src/frontends/gnome/po/de.po +++ b/src/frontends/gnome/po/de.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: NetworkManager-strongswan\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-18 18:12+0200\n" +"POT-Creation-Date: 2022-04-20 17:19+0200\n" "PO-Revision-Date: 2019-12-18 17:10+0100\n" "Last-Translator: Tobias Brunner\n" "Language-Team: de \n" @@ -17,59 +17,99 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: ../properties/nm-strongswan.c:43 +#: ../properties/nm-strongswan-plugin.c:36 msgid "IPsec/IKEv2 (strongswan)" msgstr "IPsec/IKEv2 (strongswan)" -#: ../properties/nm-strongswan.c:44 +#: ../properties/nm-strongswan-plugin.c:37 msgid "IPsec with the IKEv2 key exchange protocol." msgstr "IPsec mit dem IKEv2 Protokoll." -#: ../properties/nm-strongswan.c:367 +#: ../properties/nm-strongswan-plugin.c:80 +#, c-format +msgid "unable to determine plugin path: %s" +msgstr "Plugin-Pfad konnte nicht ermittelt werden: %s" + +#: ../properties/nm-strongswan-plugin.c:93 +#, c-format +msgid "missing plugin file '%s'" +msgstr "Plugin-Datei '%s' fehlt" + +#: ../properties/nm-strongswan-plugin.c:98 +#, c-format +msgid "unable to load editor plugin: %s" +msgstr "Laden des Editor-Plugins fehlgeschlagen: %s" + +#: ../properties/nm-strongswan-plugin.c:108 +#, c-format +msgid "cannot load factory %s from plugin: %s" +msgstr "Factory %s konnte nicht aus Plugin geladen werden: %s" + +#: ../properties/nm-strongswan-plugin.c:124 +msgid "unknown error creating editor instance" +msgstr "Unbekannter Fehler beim Erstellen der Editor-Instanz" + +#: ../properties/nm-strongswan.c:255 +msgid "(None)" +msgstr "(Nicht festgelegt)" + +#: ../properties/nm-strongswan.c:420 msgid "EAP (Username/Password)" msgstr "EAP (Benutzername/Passwort)" -#: ../properties/nm-strongswan.c:368 +#: ../properties/nm-strongswan.c:421 msgid "Certificate" msgstr "Zertifikat" -#: ../properties/nm-strongswan.c:369 +#: ../properties/nm-strongswan.c:422 msgid "EAP-TLS" msgstr "EAP-TLS" -#: ../properties/nm-strongswan.c:370 +#: ../properties/nm-strongswan.c:423 msgid "Pre-shared key" msgstr "Pre-shared Key" -#: ../properties/nm-strongswan.c:396 +#: ../properties/nm-strongswan.c:449 msgid "Certificate/private key" msgstr "Zertifikat/Privater Schlüssel" -#: ../properties/nm-strongswan.c:397 +#: ../properties/nm-strongswan.c:450 msgid "Certificate/ssh-agent" msgstr "Zertifikat/ssh-agent" -#: ../properties/nm-strongswan.c:398 +#: ../properties/nm-strongswan.c:451 msgid "Smartcard" msgstr "Smartcard" #: ../properties/nm-strongswan-dialog.ui.h:1 +msgid "Choose a server or CA certificate…" +msgstr "Server- oder CA-Zertifikat auswählen…" + +#: ../properties/nm-strongswan-dialog.ui.h:2 +msgid "_Cancel" +msgstr "Abbre_chen" + +#: ../properties/nm-strongswan-dialog.ui.h:3 +msgid "_Select" +msgstr "_Auswählen" + +#: ../properties/nm-strongswan-dialog.ui.h:4 msgid "Server" msgstr "Server" -#: ../properties/nm-strongswan-dialog.ui.h:2 +#: ../properties/nm-strongswan-dialog.ui.h:5 msgid "_Address:" msgstr "_Adresse:" -#: ../properties/nm-strongswan-dialog.ui.h:3 +#: ../properties/nm-strongswan-dialog.ui.h:6 msgid "An IP address or hostname of the VPN server." msgstr "Eine IP-Adresse oder ein Hostname des VPN Servers." -#: ../properties/nm-strongswan-dialog.ui.h:4 +#: ../properties/nm-strongswan-dialog.ui.h:7 msgid "C_ertificate:" msgstr "Z_ertifikat:" -#: ../properties/nm-strongswan-dialog.ui.h:5 +#: ../properties/nm-strongswan-dialog.ui.h:8 msgid "" "Server or CA certificate to use for server authentication. If none is " "specified, pre-installed CA certificates are used." @@ -77,11 +117,11 @@ msgstr "" "Server- oder CA-Zertifikat für die Authentisierung des Servers. Ohne Angabe " "eines Zertifikates werden die CA-Zertifikate des Systems verwendet." -#: ../properties/nm-strongswan-dialog.ui.h:6 +#: ../properties/nm-strongswan-dialog.ui.h:9 msgid "_Identity:" msgstr "_Identität:" -#: ../properties/nm-strongswan-dialog.ui.h:7 +#: ../properties/nm-strongswan-dialog.ui.h:10 msgid "" "Defaults to the server address or the server certificate's subject DN (if " "configured). Custom values are explicitly sent to the server and enforced " @@ -91,35 +131,35 @@ msgstr "" "Zertifikats (falls konfiguriert). Eigene Werte werden explizit an den Server " "gesendet und während der Authentifizierung erzwungen." -#: ../properties/nm-strongswan-dialog.ui.h:8 +#: ../properties/nm-strongswan-dialog.ui.h:11 msgid "(Defaults to address or certificate subject)" msgstr "(Standardwert ist die Adresse oder die Zertifikats-Identität)" -#: ../properties/nm-strongswan-dialog.ui.h:9 +#: ../properties/nm-strongswan-dialog.ui.h:12 msgid "Client" msgstr "Client" -#: ../properties/nm-strongswan-dialog.ui.h:10 +#: ../properties/nm-strongswan-dialog.ui.h:13 msgid "Au_thentication:" msgstr "Au_thentisierung:" -#: ../properties/nm-strongswan-dialog.ui.h:11 +#: ../properties/nm-strongswan-dialog.ui.h:14 msgid "Ce_rtificate:" msgstr "Ze_rtifikat:" -#: ../properties/nm-strongswan-dialog.ui.h:12 +#: ../properties/nm-strongswan-dialog.ui.h:15 msgid "Certificate _file:" msgstr "Z_ertifikatsdatei:" -#: ../properties/nm-strongswan-dialog.ui.h:13 +#: ../properties/nm-strongswan-dialog.ui.h:16 msgid "Client certificate to use for client authentication." msgstr "Zertifikat des Clients für dessen Authentisierung." -#: ../properties/nm-strongswan-dialog.ui.h:14 +#: ../properties/nm-strongswan-dialog.ui.h:17 msgid "Private _key:" msgstr "Privater _Schlüssel:" -#: ../properties/nm-strongswan-dialog.ui.h:15 +#: ../properties/nm-strongswan-dialog.ui.h:18 msgid "" "Private key to use for client authentication. This key has to match the " "certificates public key and may be encrypted." @@ -127,21 +167,21 @@ msgstr "" "Privater Schlüssel für die Authentisierung des Clients. Dieser Schlüssel " "muss zum konfigurierten Zertifikat passen und kann verschlüsselt sein." -#: ../properties/nm-strongswan-dialog.ui.h:16 +#: ../properties/nm-strongswan-dialog.ui.h:19 msgid "_Username:" msgstr "_Benutzername:" -#: ../properties/nm-strongswan-dialog.ui.h:17 +#: ../properties/nm-strongswan-dialog.ui.h:20 msgid "" "The username (EAP identity) to use for authentication against the server." msgstr "" "Benutzername/EAP-Identität für die Authentisierung gegenüber dem Server." -#: ../properties/nm-strongswan-dialog.ui.h:18 +#: ../properties/nm-strongswan-dialog.ui.h:21 msgid "_Password:" msgstr "_Passwort:" -#: ../properties/nm-strongswan-dialog.ui.h:19 +#: ../properties/nm-strongswan-dialog.ui.h:22 msgid "" "The password to use for authentication against the server (min. 20 " "characters for PSKs)." @@ -149,19 +189,19 @@ msgstr "" "Das Passwort für die Authentisierung gegenüber dem Server (min. 20 Zeichen " "für PSKs)." -#: ../properties/nm-strongswan-dialog.ui.h:20 +#: ../properties/nm-strongswan-dialog.ui.h:23 msgid "(Use icon to change password storage policy)" msgstr "(Icon verwenden, um Passwort-Richtlinie zu ändern)" -#: ../properties/nm-strongswan-dialog.ui.h:21 +#: ../properties/nm-strongswan-dialog.ui.h:24 msgid "_Show password" msgstr "Passwort _anzeigen" -#: ../properties/nm-strongswan-dialog.ui.h:22 +#: ../properties/nm-strongswan-dialog.ui.h:25 msgid "I_dentity:" msgstr "I_dentität:" -#: ../properties/nm-strongswan-dialog.ui.h:23 +#: ../properties/nm-strongswan-dialog.ui.h:26 msgid "" "Defaults to the username (EAP), the client certificate's subject DN " "(certificate/EAP-TLS), or the IP address (PSK). Custom values may be used if " @@ -171,15 +211,15 @@ msgstr "" "Zertifikats (Zertifikat/EAP-TLS) oder die IP-Adresse (PSK). Eigene Werte " "können verwendet werden, falls der Server diese erwartet/benötigt." -#: ../properties/nm-strongswan-dialog.ui.h:24 +#: ../properties/nm-strongswan-dialog.ui.h:27 msgid "(Defaults to username, certificate subject or IP address)" msgstr "(Standardwert ist der Benutzername, die Zertifikats-ID oder die IP)" -#: ../properties/nm-strongswan-dialog.ui.h:25 +#: ../properties/nm-strongswan-dialog.ui.h:28 msgid "Request an _inner IP address" msgstr "_Innere IP-Adresse beziehen" -#: ../properties/nm-strongswan-dialog.ui.h:26 +#: ../properties/nm-strongswan-dialog.ui.h:29 msgid "" "The server may provide addresses from a pool to use for communication in the " "VPN. Check to request such an address." @@ -188,11 +228,11 @@ msgstr "" "Kommunikation im dahinterliegenden Netz verwenden kann. Aktivieren, um eine " "solche Adresse zu beziehen." -#: ../properties/nm-strongswan-dialog.ui.h:27 +#: ../properties/nm-strongswan-dialog.ui.h:30 msgid "En_force UDP encapsulation" msgstr "Erzwingen einer zusätzlichen Einbettung der Datenpakete in _UDP" -#: ../properties/nm-strongswan-dialog.ui.h:28 +#: ../properties/nm-strongswan-dialog.ui.h:31 msgid "" "Some firewalls block ESP traffic. Enforcing UDP capsulation even if no NAT " "situation is detected might help in such cases." @@ -201,11 +241,11 @@ msgstr "" "erzwingen einer zustzlichen Einbettung in UDP, auch wenn kein NAT-Router " "detektiert wurde, kann in solchen Situationen hilfreich sein." -#: ../properties/nm-strongswan-dialog.ui.h:29 +#: ../properties/nm-strongswan-dialog.ui.h:32 msgid "Use IP c_ompression" msgstr "IP-Pakete k_omprimieren" -#: ../properties/nm-strongswan-dialog.ui.h:30 +#: ../properties/nm-strongswan-dialog.ui.h:33 msgid "" "IPComp compresses raw IP packets before they get encrypted. This saves some " "bandwidth, but uses more processing power." @@ -213,11 +253,11 @@ msgstr "" "IPComp komprimiert IP-Pakete, bevor sie verschlüsselt werden. Diese Option " "kann Bandbreite sparen, benötigt jedoch zusätzliche Rechenleistung." -#: ../properties/nm-strongswan-dialog.ui.h:31 +#: ../properties/nm-strongswan-dialog.ui.h:34 msgid "Server _port:" msgstr "Server-_Port:" -#: ../properties/nm-strongswan-dialog.ui.h:32 +#: ../properties/nm-strongswan-dialog.ui.h:35 msgid "" "Custom server port to connect to. Defaults to UDP port 500, which is " "followed by a switch to port 4500 after the first exchange." @@ -225,38 +265,46 @@ msgstr "" "Server-Port zu dem verbunden wird. Ohne Konfiguration wird UDP-Port 500 " "verwendet, mit einem Wechsel auf Port 4500 nach der ersten Nachricht." -#: ../properties/nm-strongswan-dialog.ui.h:33 +#: ../properties/nm-strongswan-dialog.ui.h:36 msgid "(Defaults to UDP 500/4500)" msgstr "(Standardwert ist UDP 500/4500)" -#: ../properties/nm-strongswan-dialog.ui.h:34 +#: ../properties/nm-strongswan-dialog.ui.h:37 msgid "Options" msgstr "Optionen" -#: ../properties/nm-strongswan-dialog.ui.h:35 +#: ../properties/nm-strongswan-dialog.ui.h:38 msgid "_Enable custom algorithm proposals" msgstr "_Eigene Algorithmen verwenden" -#: ../properties/nm-strongswan-dialog.ui.h:36 +#: ../properties/nm-strongswan-dialog.ui.h:39 msgid "_IKE:" msgstr "_IKE:" -#: ../properties/nm-strongswan-dialog.ui.h:37 +#: ../properties/nm-strongswan-dialog.ui.h:40 msgid "A list of proposals for IKE separated by \";\"" msgstr "Eine Liste von Proposals für IKE getrennt mit \";\"" -#: ../properties/nm-strongswan-dialog.ui.h:38 +#: ../properties/nm-strongswan-dialog.ui.h:41 msgid "_ESP:" msgstr "_ESP:" -#: ../properties/nm-strongswan-dialog.ui.h:39 +#: ../properties/nm-strongswan-dialog.ui.h:42 msgid "A list of proposals for ESP separated by \";\"" msgstr "Eine Liste von Proposals für ESP getrennt mit \";\"" -#: ../properties/nm-strongswan-dialog.ui.h:40 +#: ../properties/nm-strongswan-dialog.ui.h:43 msgid "Algorithms" msgstr "Algorithmen" +#: ../properties/nm-strongswan-dialog.ui.h:44 +msgid "Choose a client certificate…" +msgstr "Client-Zertifikat auswählen…" + +#: ../properties/nm-strongswan-dialog.ui.h:45 +msgid "Choose a private key…" +msgstr "Privaten Schlüssel auswählen…" + #: ../auth-dialog/main.c:137 #, c-format msgid "EAP password required to establish VPN connection '%s'." diff --git a/src/frontends/gnome/properties/Makefile.am b/src/frontends/gnome/properties/Makefile.am index 317305d6f..28af9f569 100644 --- a/src/frontends/gnome/properties/Makefile.am +++ b/src/frontends/gnome/properties/Makefile.am @@ -1,50 +1,107 @@ -nm_plugin_LTLIBRARIES = libnm-vpn-plugin-strongswan.la +nm_plugin_LTLIBRARIES = \ + libnm-vpn-plugin-strongswan.la \ + libnm-vpn-plugin-strongswan-editor.la -if WITH_LIBNM_GLIB -nm_plugin_LTLIBRARIES += libnm-strongswan-properties.la +if WITH_GTK4 +nm_plugin_LTLIBRARIES += \ + libnm-gtk4-vpn-plugin-strongswan-editor.la endif +nm-strongswan-resources.h: nm-strongswan-dialog.gresource.xml + $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ --sourcedir=$(srcdir) \ + --generate-header --internal + +nm-strongswan-resources.c: nm-strongswan-dialog.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/nm-strongswan-dialog.gresource.xml) + $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ --sourcedir=$(srcdir) \ + --generate-source --internal + +gtk4/nm-strongswan-resources.c: nm-strongswan-dialog.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/nm-strongswan-dialog.gresource.xml|sed "s,^$(srcdir)/,$(builddir)/gtk4/,") + @mkdir -p $(builddir)/gtk4 + $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ \ + --sourcedir=$(srcdir)/gtk4 --sourcedir=$(builddir)/gtk4 \ + --generate-source --internal + +gtk4/%.ui: %.ui + @mkdir -p $(builddir)/gtk4 + gtk4-builder-tool simplify --3to4 $< | grep -v 'border-width\|can-default\|has-default' >$@ + libnm_vpn_plugin_strongswan_la_SOURCES = \ + nm-strongswan-plugin.c \ + nm-strongswan-plugin.h + +nodist_libnm_vpn_plugin_strongswan_editor_la_SOURCES = \ + nm-strongswan-resources.c \ + nm-strongswan-resources.h + +libnm_vpn_plugin_strongswan_editor_la_SOURCES = \ nm-strongswan.c \ nm-strongswan.h -libnm_strongswan_properties_la_SOURCES = \ - $(libnm_vpn_plugin_strongswan_la_SOURCES) +nodist_libnm_gtk4_vpn_plugin_strongswan_editor_la_SOURCES = \ + gtk4/nm-strongswan-resources.c \ + nm-strongswan-resources.h -uidir = $(datadir)/gnome-vpn-properties/strongswan -ui_DATA = nm-strongswan-dialog.ui +libnm_gtk4_vpn_plugin_strongswan_editor_la_SOURCES = \ + $(libnm_vpn_plugin_strongswan_editor_la_SOURCES) common_CFLAGS = \ - $(GTK_CFLAGS) \ - -DUIDIR=\""$(uidir)"\" \ -DG_DISABLE_DEPRECATED \ -DGDK_DISABLE_DEPRECATED libnm_vpn_plugin_strongswan_la_CFLAGS = \ + $(LIBNM_CFLAGS) \ + $(common_CFLAGS) + +libnm_vpn_plugin_strongswan_editor_la_CFLAGS = \ + $(GTK_CFLAGS) \ $(LIBNM_CFLAGS) \ $(LIBNMA_CFLAGS) \ $(common_CFLAGS) -libnm_strongswan_properties_la_CFLAGS = \ - -DNM_STRONGSWAN_OLD \ - $(LIBNM_GTK_CFLAGS) \ - $(LIBNM_GLIB_CFLAGS) \ +libnm_gtk4_vpn_plugin_strongswan_editor_la_CFLAGS = \ + $(GTK4_CFLAGS) \ + $(LIBNM_CFLAGS) \ + $(LIBNMA_GTK4_CFLAGS) \ $(common_CFLAGS) libnm_vpn_plugin_strongswan_la_LIBADD = \ + $(LIBNM_LIBS) \ + $(DL_LIBS) + +libnm_vpn_plugin_strongswan_editor_la_LIBADD = \ $(GTK_LIBS) \ $(LIBNMA_LIBS) \ $(LIBNM_LIBS) -libnm_strongswan_properties_la_LIBADD = \ - $(GTK_LIBS) \ - $(LIBNM_GTK_LIBS) \ - $(LIBNM_GLIB_LIBS) +libnm_gtk4_vpn_plugin_strongswan_editor_la_LIBADD = \ + $(GTK4_LIBS) \ + $(LIBNMA_GTK4_LIBS) \ + $(LIBNM_LIBS) libnm_vpn_plugin_strongswan_la_LDFLAGS = \ -avoid-version -libnm_strongswan_properties_la_LDFLAGS = \ - $(libnm_vpn_plugin_strongswan_la_LDFLAGS) +libnm_vpn_plugin_strongswan_editor_la_LDFLAGS = \ + -avoid-version -EXTRA_DIST = $(ui_DATA) +libnm_gtk4_vpn_plugin_strongswan_editor_la_LDFLAGS = \ + -avoid-version + +BUILT_SOURCES = \ + nm-strongswan-resources.c \ + nm-strongswan-resources.h + +if WITH_GTK4 +BUILT_SOURCES += \ + gtk4/nm-strongswan-resources.c +endif + +CLEANFILES = \ + nm-strongswan-resources.c \ + nm-strongswan-resources.h \ + gtk4/nm-strongswan-resources.c \ + gtk4/nm-strongswan-dialog.ui + +EXTRA_DIST = \ + nm-strongswan-dialog.ui \ + nm-strongswan-dialog.gresource.xml diff --git a/src/frontends/gnome/properties/nm-strongswan-dialog.gresource.xml b/src/frontends/gnome/properties/nm-strongswan-dialog.gresource.xml new file mode 100644 index 000000000..2e4e16782 --- /dev/null +++ b/src/frontends/gnome/properties/nm-strongswan-dialog.gresource.xml @@ -0,0 +1,6 @@ + + + + nm-strongswan-dialog.ui + + diff --git a/src/frontends/gnome/properties/nm-strongswan-dialog.ui b/src/frontends/gnome/properties/nm-strongswan-dialog.ui index 7320ba47c..66b170c0a 100644 --- a/src/frontends/gnome/properties/nm-strongswan-dialog.ui +++ b/src/frontends/gnome/properties/nm-strongswan-dialog.ui @@ -1,25 +1,78 @@ - + - + + + False + True + + + True + False + False + + + Choose a server or CA certificate… + True + False + + + + + + _Cancel + True + True + False + True + + + + + _Select + True + True + True + True + True + True + + + + 1 + end + + + + + + certificate-chooser-cancel + certificate-chooser-accept + + True - False - 12 + False + 12 vertical 12 True - False + False vertical 6 True - False + False <b>Server</b> - True + True 0 @@ -29,91 +82,118 @@ + True - False - 12 - 6 - 6 - True + False + 12 + 6 + 6 + True True - False + False _Address: - True + True 0 - 0 - 0 + 0 + 0 True - True - An IP address or hostname of the VPN server. + True + An IP address or hostname of the VPN server. True - False - False - 1 - 0 + 1 + 0 True - False + False C_ertificate: - True + True 0 - 0 - 1 + 0 + 1 - + True - False - Server or CA certificate to use for server authentication. If none is specified, pre-installed CA certificates are used. - True + False + False + Server or CA certificate to use for server authentication. If none is specified, pre-installed CA certificates are used. + + + True + False + + + True + False + 0 + + + True + True + 0 + + + + + True + False + document-open-symbolic + + + False + True + 1 + + + + - 1 - 1 + 1 + 1 True - False + False _Identity: - True + True 0 - 0 - 2 + 0 + 2 True - True - Defaults to the server address or the server certificate's subject DN (if configured). Custom values are explicitly sent to the server and enforced during authentication. + True + Defaults to the server address or the server certificate's subject DN (if configured). Custom values are explicitly sent to the server and enforced during authentication. True - False - False - (Defaults to address or certificate subject) + (Defaults to address or certificate subject) - 1 - 2 + 1 + 2 @@ -133,15 +213,15 @@ True - False + False vertical 6 True - False + False <b>Client</b> - True + True 0 @@ -151,208 +231,263 @@ + True - False - 12 - 6 - 6 - True + False + 12 + 6 + 6 + True True - False + False Au_thentication: - True + True 0 - 0 - 0 + 0 + 0 True - False + False True - 1 - 0 + 1 + 0 True - False + False Ce_rtificate: - True + True 0 - 0 - 1 + 0 + 1 True - False + False True - 1 - 1 + 1 + 1 True - False + False Certificate _file: - True + True 0 - 0 - 2 + 0 + 2 - + True - False - Client certificate to use for client authentication. - True + False + False + Client certificate to use for client authentication. + + + True + False + + + True + False + 0 + + + True + True + 0 + + + + + True + False + document-open-symbolic + + + False + True + 1 + + + + - 1 - 2 + 1 + 2 True - False + False Private _key: - True + True 0 - 0 - 3 + 0 + 3 - + True - False - Private key to use for client authentication. This key has to match the certificates public key and may be encrypted. - True + False + False + Private key to use for client authentication. This key has to match the certificates public key and may be encrypted. + + + True + False + + + True + False + 0 + + + True + True + 0 + + + + + True + False + document-open-symbolic + + + False + True + 1 + + + + - 1 - 3 + 1 + 3 True - False + False _Username: - True + True 0 - 0 - 5 + 0 + 5 True - True - The username (EAP identity) to use for authentication against the server. + True + The username (EAP identity) to use for authentication against the server. True - False - False - 1 - 5 + 1 + 5 True - False + False _Password: - True + True 0 - 0 - 6 + 0 + 6 True - True - The password to use for authentication against the server (min. 20 characters for PSKs). + True + The password to use for authentication against the server (min. 20 characters for PSKs). True False - False - False - (Use icon to change password storage policy) + (Use icon to change password storage policy) - 1 - 6 + 1 + 6 _Show password True - True - False + True + False True - True - True + True + True - 1 - 7 + 1 + 7 True - False + False I_dentity: - True + True 0 - 0 - 4 + 0 + 4 True - True - Defaults to the username (EAP), the client certificate's subject DN (certificate/EAP-TLS), or the IP address (PSK). Custom values may be used if expected/required by the server. + True + Defaults to the username (EAP), the client certificate's subject DN (certificate/EAP-TLS), or the IP address (PSK). Custom values may be used if expected/required by the server. True - False - False - (Defaults to username, certificate subject or IP address) + (Defaults to username, certificate subject or IP address) - 1 - 4 + 1 + 4 @@ -375,25 +510,25 @@ True - True - left + True + left True - False + False start - 6 vertical + 6 6 Request an _inner IP address True - True - False - The server may provide addresses from a pool to use for communication in the VPN. Check to request such an address. - True - True + True + False + The server may provide addresses from a pool to use for communication in the VPN. Check to request such an address. + True + True True @@ -405,11 +540,11 @@ En_force UDP encapsulation True - True - False - Some firewalls block ESP traffic. Enforcing UDP capsulation even if no NAT situation is detected might help in such cases. - True - True + True + False + Some firewalls block ESP traffic. Enforcing UDP capsulation even if no NAT situation is detected might help in such cases. + True + True True @@ -421,11 +556,11 @@ Use IP c_ompression True - True - False - IPComp compresses raw IP packets before they get encrypted. This saves some bandwidth, but uses more processing power. - True - True + True + False + IPComp compresses raw IP packets before they get encrypted. This saves some bandwidth, but uses more processing power. + True + True True @@ -434,39 +569,38 @@ + True - False - 6 - 6 - True + False + 6 + 6 + True True - False + False Server _port: - True + True 0 - 0 - 0 + 0 + 0 True - True - Custom server port to connect to. Defaults to UDP port 500, which is followed by a switch to port 4500 after the first exchange. + True + Custom server port to connect to. Defaults to UDP port 500, which is followed by a switch to port 4500 after the first exchange. True - - False - False - (Defaults to UDP 500/4500) + + (Defaults to UDP 500/4500) - 1 - 0 + 1 + 0 @@ -481,29 +615,29 @@ True - False + False Options - False + False True - False + False start - 6 vertical + 6 6 _Enable custom algorithm proposals True - True - False - True - True + True + False + True + True True @@ -512,66 +646,63 @@ + True - False - 6 - 6 - True + False + 6 + 6 + True True - False + False _IKE: - True + True 0 - 0 - 0 + 0 + 0 True - True - A list of proposals for IKE separated by ";" + True + A list of proposals for IKE separated by ";" True - - False - False + - 1 - 0 + 1 + 0 True - False + False _ESP: - True + True 0 - 0 - 1 + 0 + 1 True - True - A list of proposals for ESP separated by ";" + True + A list of proposals for ESP separated by ";" True - - False - False + - 1 - 1 + 1 + 1 @@ -589,12 +720,12 @@ True - False + False Algorithms 1 - False + False @@ -611,4 +742,110 @@ + + False + True + + + True + False + False + + + Choose a client certificate… + True + False + + + + + + _Cancel + True + True + False + True + + + + + _Select + True + True + True + True + True + True + + + + 1 + end + + + + + + usercert-chooser-cancel + usercert-chooser-accept + + + + False + True + + + True + False + False + + + Choose a private key… + True + False + + + + + + _Cancel + True + True + False + True + + + + + _Select + True + True + True + True + True + True + + + + 1 + end + + + + + + userkey-chooser-cancel + userkey-chooser-accept + + diff --git a/src/frontends/gnome/properties/nm-strongswan-plugin.c b/src/frontends/gnome/properties/nm-strongswan-plugin.c new file mode 100644 index 000000000..57320088e --- /dev/null +++ b/src/frontends/gnome/properties/nm-strongswan-plugin.c @@ -0,0 +1,218 @@ +/* + * Copyright (C) 2013-2020 Tobias Brunner + * Copyright (C) 2008 Martin Willi + * HSR Hochschule fuer Technik Rapperswil + * Copyright (C) 2015 Lubomir Rintel + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#define _GNU_SOURCE +#include + +#include +#include + +#include + +#include "nm-strongswan-plugin.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 STRONGSWAN_EDITOR_GTK3 "libnm-vpn-plugin-strongswan-editor.so" +#define STRONGSWAN_EDITOR_GTK4 "libnm-gtk4-vpn-plugin-strongswan-editor.so" +#define STRONGSWAN_EDITOR_FACTORY "strongswan_editor_new" + +/************** plugin class **************/ + +enum { + PROP_0, + PROP_NAME, + PROP_DESC, + PROP_SERVICE +}; + +static void strongswan_plugin_ui_interface_init (NMVpnEditorPluginInterface *iface_class); + +G_DEFINE_TYPE_EXTENDED (StrongswanPluginUi, strongswan_plugin_ui, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR_PLUGIN, + strongswan_plugin_ui_interface_init)) + +static NMVpnEditor * +get_editor (NMVpnEditorPlugin *iface, NMConnection *connection, GError **error) +{ + static struct { + NMVpnEditor *(*factory)(NMConnection*, GError**); + void *dl_module; + char *file; + } cache = {}; + NMVpnEditor *editor; + char *file; + + g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + g_return_val_if_fail (!error || !*error, NULL); + + /* check for a GTK3-only symbol to decide which editor to load */ + if (dlsym(RTLD_DEFAULT, "gtk_container_add")) + { + file = STRONGSWAN_EDITOR_GTK3; + } + else + { + + file = STRONGSWAN_EDITOR_GTK4; + } + + if (cache.factory) + { /* we can't switch GTK versions */ + g_return_val_if_fail (cache.file && !strcmp(cache.file, file), NULL); + } + else + { + Dl_info plugin_info; + void *dl_module; + char *module_path = NULL; + char *dirname = NULL; + NMVpnEditor *(*factory)(NMConnection*, GError**); + + if (!dladdr(get_editor, &plugin_info)) + { + g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_FAILED, + _("unable to determine plugin path: %s"), dlerror()); + return NULL; + } + dirname = g_path_get_dirname (plugin_info.dli_fname); + module_path = g_build_filename (dirname, file, NULL); + g_free(dirname); + + dl_module = dlopen(module_path, RTLD_LAZY | RTLD_LOCAL); + if (!dl_module) + { + if (!g_file_test (module_path, G_FILE_TEST_EXISTS)) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_NOENT, + _("missing plugin file '%s'"), module_path); + g_free(module_path); + return NULL; + } + g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_FAILED, + _("unable to load editor plugin: %s"), dlerror ()); + g_free(module_path); + return NULL; + } + g_free(module_path); + + factory = dlsym (dl_module, STRONGSWAN_EDITOR_FACTORY); + if (!factory) + { + g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_FAILED, + _("cannot load factory %s from plugin: %s"), + STRONGSWAN_EDITOR_FACTORY, dlerror ()); + dlclose (dl_module); + return NULL; + } + cache.factory = factory; + cache.dl_module = dl_module; + cache.file = strdup(file); + } + + editor = cache.factory (connection, error); + if (!editor) + { + if (error && !*error) + { + g_set_error_literal (error, NM_VPN_PLUGIN_ERROR, + NM_VPN_PLUGIN_ERROR_FAILED, + _("unknown error creating editor instance")); + return NULL; + } + return NULL; + } + g_return_val_if_fail (NM_IS_VPN_EDITOR (editor), NULL); + return editor; +} + +static guint32 +get_capabilities (NMVpnEditorPlugin *iface) +{ + return NM_VPN_EDITOR_PLUGIN_CAPABILITY_IPV6; +} + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + switch (prop_id) { + case PROP_NAME: + g_value_set_string (value, STRONGSWAN_PLUGIN_NAME); + break; + case PROP_DESC: + g_value_set_string (value, STRONGSWAN_PLUGIN_DESC); + break; + case 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); + + object_class->get_property = get_property; + + g_object_class_override_property (object_class, + PROP_NAME, + NM_VPN_EDITOR_PLUGIN_NAME); + + g_object_class_override_property (object_class, + PROP_DESC, + NM_VPN_EDITOR_PLUGIN_DESCRIPTION); + + g_object_class_override_property (object_class, + PROP_SERVICE, + NM_VPN_EDITOR_PLUGIN_SERVICE); +} + +static void +strongswan_plugin_ui_init (StrongswanPluginUi *plugin) +{ +} + +static void +strongswan_plugin_ui_interface_init (NMVpnEditorPluginInterface *iface_class) +{ + /* interface implementation */ + iface_class->get_editor = get_editor; + iface_class->get_capabilities = get_capabilities; + /* TODO: implement delete_connection to purge associated secrets */ +} + +G_MODULE_EXPORT NMVpnEditorPlugin * +nm_vpn_editor_plugin_factory (GError **error) +{ + g_return_val_if_fail (!error || !*error, NULL); + + return g_object_new (STRONGSWAN_TYPE_PLUGIN_UI, NULL); +} diff --git a/src/frontends/gnome/properties/nm-strongswan-plugin.h b/src/frontends/gnome/properties/nm-strongswan-plugin.h new file mode 100644 index 000000000..e2a55038c --- /dev/null +++ b/src/frontends/gnome/properties/nm-strongswan-plugin.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2008 Martin Willi + * HSR 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. + */ + +#ifndef _NM_STRONGSWAN_PLUGIN_H_ +#define _NM_STRONGSWAN_PLUGIN_H_ + +#include + +#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); + +#endif /* _NM_STRONGSWAN_PLUGIN_H_ */ diff --git a/src/frontends/gnome/properties/nm-strongswan.c b/src/frontends/gnome/properties/nm-strongswan.c index 07bfb1c56..ed706c498 100644 --- a/src/frontends/gnome/properties/nm-strongswan.c +++ b/src/frontends/gnome/properties/nm-strongswan.c @@ -27,38 +27,29 @@ #include #include -#ifdef NM_STRONGSWAN_OLD -#define NM_VPN_LIBNM_COMPAT -#include -#include -#include -#include -#else #include #include -#endif #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" +#define NM_DBUS_PATH_STRONGSWAN "/org/freedesktop/NetworkManager/strongswan" +#define STRONGSWAN_UI_RESOURCE NM_DBUS_PATH_STRONGSWAN "/nm-strongswan-dialog.ui" -/************** plugin class **************/ - -enum { - PROP_0, - PROP_NAME, - PROP_DESC, - PROP_SERVICE -}; - -static void strongswan_plugin_ui_interface_init (NMVpnEditorPluginInterface *iface_class); - -G_DEFINE_TYPE_EXTENDED (StrongswanPluginUi, strongswan_plugin_ui, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR_PLUGIN, - strongswan_plugin_ui_interface_init)) +#if !GTK_CHECK_VERSION(4,0,0) +typedef void GtkRoot; +#define gtk_editable_set_text(editable, text) gtk_entry_set_text(GTK_ENTRY(editable), (text)) +#define gtk_editable_get_text(editable) gtk_entry_get_text(GTK_ENTRY(editable)) +#define gtk_check_button_get_active(button) gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)) +#define gtk_check_button_set_active(button, active) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active) +#define gtk_widget_get_root(widget) gtk_widget_get_toplevel(widget) +#define gtk_window_set_hide_on_close(window, hide) \ + G_STMT_START { \ + G_STATIC_ASSERT (hide); \ + g_signal_connect_swapped (G_OBJECT (window), "delete-event", \ + G_CALLBACK (gtk_widget_hide_on_delete), window); \ + } G_STMT_END +#endif /************** UI widget class **************/ @@ -119,7 +110,7 @@ check_validity (StrongswanPluginUiWidget *self, GError **error) char *str; widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "address-entry")); - str = (char *) gtk_entry_get_text (GTK_ENTRY (widget)); + str = (char *) gtk_editable_get_text (GTK_EDITABLE (widget)); if (!str || !strlen (str)) { g_set_error (error, STRONGSWAN_PLUGIN_UI_ERROR, @@ -137,7 +128,7 @@ check_validity (StrongswanPluginUiWidget *self, GError **error) { case NM_SETTING_SECRET_FLAG_NONE: case NM_SETTING_SECRET_FLAG_AGENT_OWNED: - str = (char *) gtk_entry_get_text (GTK_ENTRY (widget)); + str = (char *) gtk_editable_get_text (GTK_EDITABLE (widget)); if (str && strlen (str) < 20) { g_set_error (error, STRONGSWAN_PLUGIN_UI_ERROR, @@ -246,7 +237,7 @@ show_toggled_cb (GtkCheckButton *button, StrongswanPluginUiWidget *self) GtkWidget *widget; gboolean visible; - visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); + visible = gtk_check_button_get_active (GTK_CHECK_BUTTON (button)); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "passwd-entry")); gtk_entry_set_visibility (GTK_ENTRY (widget), visible); @@ -256,11 +247,64 @@ static void toggle_proposal_cb(GtkCheckButton *button, StrongswanPluginUiWidget *self) { StrongswanPluginUiWidgetPrivate *priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (self); - gboolean visible = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); + gboolean visible = gtk_check_button_get_active(GTK_CHECK_BUTTON(button)); gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(priv->builder, "ike-entry")), visible); gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(priv->builder, "esp-entry")), visible); } +static void +chooser_button_update_file (GtkLabel *label, GFile *file) +{ + char *basename = NULL; + + if (file) + basename = g_file_get_basename (file); + + if (basename) + { + gtk_label_set_label (label, basename); + g_free (basename); + } + else + { + gtk_label_set_label (label, _("(None)")); + } +} + +static void +chooser_button_update (GtkLabel *label, GtkFileChooser *chooser) +{ + GFile *file; + + file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (chooser)); + chooser_button_update_file (label, file); + g_clear_object (&file); +} + +static void +chooser_response_cb (GtkDialog *chooser, gint response_id, gpointer user_data) +{ + GtkLabel *label = GTK_LABEL (user_data); + + if (response_id == GTK_RESPONSE_ACCEPT) + { + chooser_button_update (label, GTK_FILE_CHOOSER (chooser)); + } + gtk_widget_hide (GTK_WIDGET (chooser)); +} + +static void +chooser_show_cb (GtkWidget *parent, GtkWidget *widget) +{ + GtkRoot *root; + + root = gtk_widget_get_root (parent); + g_return_if_fail (GTK_IS_WINDOW (root)); + + gtk_window_set_transient_for (GTK_WINDOW (widget), GTK_WINDOW (root)); + gtk_widget_show (widget); +} + static void password_storage_changed_cb (GObject *entry, GParamSpec *pspec, gpointer user_data) { @@ -291,7 +335,7 @@ init_password_icon (StrongswanPluginUiWidget *self, NMSettingVpn *settings, nm_setting_get_secret_flags (NM_SETTING (settings), secret_key, &pw_flags, NULL); } - value = gtk_entry_get_text (GTK_ENTRY (entry)); + value = gtk_editable_get_text (GTK_EDITABLE (entry)); if ((!value || !*value) && (pw_flags == NM_SETTING_SECRET_FLAG_NONE)) { nma_utils_update_password_storage (entry, NM_SETTING_SECRET_FLAG_NOT_SAVED, @@ -302,6 +346,32 @@ init_password_icon (StrongswanPluginUiWidget *self, NMSettingVpn *settings, G_CALLBACK (password_storage_changed_cb), self); } +static void +init_chooser (GtkBuilder *builder, NMSettingVpn *settings, const char *setting, + const char *chooser, const char *button, const char *label_name) +{ + GtkWidget *widget; + GtkLabel *label; + GFile *file = NULL; + const char *value; + + widget = GTK_WIDGET (gtk_builder_get_object (builder, chooser)); + label = GTK_LABEL (gtk_builder_get_object (builder, label_name)); + gtk_window_set_hide_on_close (GTK_WINDOW(widget), TRUE); + value = nm_setting_vpn_get_data_item (settings, setting); + if (value) + { + file = g_file_new_for_path (value); + gtk_file_chooser_set_file (GTK_FILE_CHOOSER (widget), file, NULL); + } + g_signal_connect (G_OBJECT (widget), "response", + G_CALLBACK (chooser_response_cb), label); + g_signal_connect (gtk_builder_get_object (builder, button), + "clicked", G_CALLBACK (chooser_show_cb), widget); + chooser_button_update_file (label, file); + g_clear_object (&file); +} + static gboolean init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError **error) { @@ -317,25 +387,22 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "address-entry")); value = nm_setting_vpn_get_data_item (settings, "address"); if (value) - gtk_entry_set_text (GTK_ENTRY (widget), value); + gtk_editable_set_text (GTK_EDITABLE (widget), value); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self); - widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "certificate-button")); - value = nm_setting_vpn_get_data_item (settings, "certificate"); - if (value) - gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), value); - g_signal_connect (G_OBJECT (widget), "selection-changed", G_CALLBACK (settings_changed_cb), self); + init_chooser (priv->builder, settings, "certificate", "certificate-chooser", + "certificate-button", "certificate-button-label"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "remote-identity-entry")); value = nm_setting_vpn_get_data_item (settings, "remote-identity"); if (value) - gtk_entry_set_text (GTK_ENTRY (widget), value); + gtk_editable_set_text (GTK_EDITABLE (widget), value); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "server-port-entry")); value = nm_setting_vpn_get_data_item (settings, "server-port"); if (value) - gtk_entry_set_text (GTK_ENTRY (widget), value); + gtk_editable_set_text (GTK_EDITABLE (widget), value); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "local-identity-entry")); @@ -344,14 +411,14 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError if (!value && method && g_strcmp0 (method, "psk") == 0) value = nm_setting_vpn_get_data_item (settings, "user"); if (value) - gtk_entry_set_text (GTK_ENTRY (widget), value); + gtk_editable_set_text (GTK_EDITABLE (widget), value); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "user-entry")); value = nm_setting_vpn_get_data_item (settings, "user"); /* PSK auth now uses local identity, see above */ if (value && method && g_strcmp0 (method, "psk") != 0) - gtk_entry_set_text (GTK_ENTRY (widget), value); + gtk_editable_set_text (GTK_EDITABLE (widget), value); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "passwd-show")); @@ -359,7 +426,7 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "passwd-entry")); value = nm_setting_vpn_get_secret (settings, "password"); if (value) - gtk_entry_set_text (GTK_ENTRY (widget), value); + gtk_editable_set_text (GTK_EDITABLE (widget), value); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self); init_password_icon (self, settings, "password", "passwd-entry"); @@ -420,23 +487,17 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self); update_sensitive (priv); - widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "usercert-button")); - value = nm_setting_vpn_get_data_item (settings, "usercert"); - if (value) - gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), value); - g_signal_connect (G_OBJECT (widget), "selection-changed", G_CALLBACK (settings_changed_cb), self); + init_chooser (priv->builder, settings, "usercert", "usercert-chooser", + "usercert-button", "usercert-button-label"); - widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "userkey-button")); - value = nm_setting_vpn_get_data_item (settings, "userkey"); - if (value) - gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), value); - g_signal_connect (G_OBJECT (widget), "selection-changed", G_CALLBACK (settings_changed_cb), self); + init_chooser (priv->builder, settings, "userkey", "userkey-chooser", + "userkey-button", "userkey-button-label"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "virtual-check")); value = nm_setting_vpn_get_data_item (settings, "virtual"); if (value && strcmp(value, "yes") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE); + gtk_check_button_set_active(GTK_CHECK_BUTTON(widget), TRUE); } g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (settings_changed_cb), self); @@ -444,7 +505,7 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError value = nm_setting_vpn_get_data_item (settings, "encap"); if (value && strcmp(value, "yes") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE); + gtk_check_button_set_active(GTK_CHECK_BUTTON(widget), TRUE); } g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (settings_changed_cb), self); @@ -452,14 +513,14 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError value = nm_setting_vpn_get_data_item (settings, "ipcomp"); if (value && strcmp(value, "yes") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE); + gtk_check_button_set_active(GTK_CHECK_BUTTON(widget), TRUE); } g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (settings_changed_cb), self); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "proposal-check")); value = nm_setting_vpn_get_data_item(settings, "proposal"); if (value && strcmp(value, "yes") == 0) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE); + gtk_check_button_set_active(GTK_CHECK_BUTTON(widget), TRUE); else toggle_proposal_cb(GTK_CHECK_BUTTON(widget), self); g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (toggle_proposal_cb), self); @@ -469,7 +530,7 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError if (value) { value = g_strdelimit (g_strdup (value), ";", ','); - gtk_entry_set_text (GTK_ENTRY (widget), value); + gtk_editable_set_text (GTK_EDITABLE (widget), value); g_free ((char*)value); } g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self); @@ -479,7 +540,7 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError if (value) { value = g_strdelimit (g_strdup (value), ";", ','); - gtk_entry_set_text (GTK_ENTRY (widget), value); + gtk_editable_set_text (GTK_EDITABLE (widget), value); g_free ((char*)value); } g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self); @@ -513,7 +574,7 @@ save_password_and_flags (NMSettingVpn *settings, GtkBuilder *builder, case NM_SETTING_SECRET_FLAG_NONE: /* FALL */ case NM_SETTING_SECRET_FLAG_AGENT_OWNED: - password = gtk_entry_get_text (GTK_ENTRY (entry)); + password = gtk_editable_get_text (GTK_EDITABLE (entry)); if (password && strlen (password)) { nm_setting_vpn_add_secret (settings, secret_key, password); @@ -527,19 +588,24 @@ save_password_and_flags (NMSettingVpn *settings, GtkBuilder *builder, nm_setting_set_secret_flags (NM_SETTING (settings), secret_key, flags, NULL); } - static void save_file_chooser (NMSettingVpn *settings, GtkBuilder *builder, const char *name, const char *key) { GtkWidget *chooser; - char *str; + GFile *file; + char *str = NULL; chooser = GTK_WIDGET (gtk_builder_get_object (builder, name)); - str = (char *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser)); - if (str) { + file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (chooser)); + if (file) { + str = g_file_get_path (file); + } + if (str && strlen(str)) { nm_setting_vpn_add_data_item (settings, key, str); } + g_free (str); + g_clear_object (&file); } static void @@ -550,7 +616,7 @@ save_entry (NMSettingVpn *settings, GtkBuilder *builder, const char *str; entry = GTK_WIDGET (gtk_builder_get_object (builder, name)); - str = (char *) gtk_entry_get_text (GTK_ENTRY (entry)); + str = (char *) gtk_editable_get_text (GTK_EDITABLE (entry)); if (str && strlen (str)) { nm_setting_vpn_add_data_item (settings, key, str); } @@ -586,10 +652,10 @@ save_cert (NMSettingVpn *settings, GtkBuilder *builder) nm_setting_vpn_add_data_item (settings, "cert-source", str); if (cert) { - save_file_chooser (settings, builder, "usercert-button", "usercert"); + save_file_chooser (settings, builder, "usercert-chooser", "usercert"); } if (key) { - save_file_chooser (settings, builder, "userkey-button", "userkey"); + save_file_chooser (settings, builder, "userkey-chooser", "userkey"); } } @@ -613,7 +679,7 @@ update_connection (NMVpnEditor *iface, NM_DBUS_SERVICE_STRONGSWAN, NULL); save_entry (settings, priv->builder, "address-entry", "address"); - save_file_chooser (settings, priv->builder, "certificate-button", "certificate"); + save_file_chooser (settings, priv->builder, "certificate-chooser", "certificate"); save_entry (settings, priv->builder, "remote-identity-entry", "remote-identity"); save_entry (settings, priv->builder, "server-port-entry", "server-port"); save_entry (settings, priv->builder, "local-identity-entry", "local-identity"); @@ -644,23 +710,23 @@ update_connection (NMVpnEditor *iface, nm_setting_vpn_add_data_item (settings, "method", str); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "virtual-check")); - active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + active = gtk_check_button_get_active(GTK_CHECK_BUTTON(widget)); nm_setting_vpn_add_data_item (settings, "virtual", active ? "yes" : "no"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "encap-check")); - active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + active = gtk_check_button_get_active(GTK_CHECK_BUTTON(widget)); nm_setting_vpn_add_data_item (settings, "encap", active ? "yes" : "no"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "ipcomp-check")); - active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + active = gtk_check_button_get_active(GTK_CHECK_BUTTON(widget)); nm_setting_vpn_add_data_item (settings, "ipcomp", active ? "yes" : "no"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "proposal-check")); - active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + active = gtk_check_button_get_active(GTK_CHECK_BUTTON(widget)); nm_setting_vpn_add_data_item (settings, "proposal", active ? "yes" : "no"); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "ike-entry")); - str = (char *) gtk_entry_get_text (GTK_ENTRY (widget)); + str = (char *) gtk_editable_get_text (GTK_EDITABLE (widget)); if (str && strlen (str)) { str = g_strdelimit (g_strdup (str), ",", ';'); nm_setting_vpn_add_data_item (settings, "ike", str); @@ -668,7 +734,7 @@ update_connection (NMVpnEditor *iface, } widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "esp-entry")); - str = (char *) gtk_entry_get_text (GTK_ENTRY (widget)); + str = (char *) gtk_editable_get_text (GTK_EDITABLE (widget)); if (str && strlen (str)) { str = g_strdelimit (g_strdup (str), ",", ';'); nm_setting_vpn_add_data_item (settings, "esp", str); @@ -679,56 +745,6 @@ update_connection (NMVpnEditor *iface, return TRUE; } -static NMVpnEditor * -nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) -{ - NMVpnEditor *object; - StrongswanPluginUiWidgetPrivate *priv; - char *ui_file; - - if (error) - g_return_val_if_fail (*error == NULL, NULL); - - object = 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 ((StrongswanPluginUiWidget*)object); - ui_file = g_strdup_printf ("%s/%s", UIDIR, "nm-strongswan-dialog.ui"); - priv->builder = gtk_builder_new (); - - gtk_builder_set_translation_domain (priv->builder, GETTEXT_PACKAGE); - - if (!gtk_builder_add_from_file (priv->builder, ui_file, error)) { - g_warning ("Couldn't load builder file: %s", - error && *error ? (*error)->message : "(unknown)"); - g_clear_error (error); - g_set_error (error, STRONGSWAN_PLUGIN_UI_ERROR, 0, - "could not load required resources at %s", ui_file); - g_free (ui_file); - g_object_unref (object); - return NULL; - } - g_free (ui_file); - - priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "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) { @@ -769,78 +785,45 @@ strongswan_plugin_ui_widget_interface_init (NMVpnEditorInterface *iface_class) iface_class->update_connection = update_connection; } -static guint32 -get_capabilities (NMVpnEditorPlugin *iface) +NMVpnEditor * +strongswan_editor_new (NMConnection *connection, GError **error) { - return NM_VPN_EDITOR_PLUGIN_CAPABILITY_IPV6; -} + NMVpnEditor *object; + StrongswanPluginUiWidgetPrivate *priv; -static NMVpnEditor * -get_editor (NMVpnEditorPlugin *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 PROP_NAME: - g_value_set_string (value, STRONGSWAN_PLUGIN_NAME); - break; - case PROP_DESC: - g_value_set_string (value, STRONGSWAN_PLUGIN_DESC); - break; - case 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); - - object_class->get_property = get_property; - - g_object_class_override_property (object_class, - PROP_NAME, - NM_VPN_EDITOR_PLUGIN_NAME); - - g_object_class_override_property (object_class, - PROP_DESC, - NM_VPN_EDITOR_PLUGIN_DESCRIPTION); - - g_object_class_override_property (object_class, - PROP_SERVICE, - NM_VPN_EDITOR_PLUGIN_SERVICE); -} - -static void -strongswan_plugin_ui_init (StrongswanPluginUi *plugin) -{ -} - -static void -strongswan_plugin_ui_interface_init (NMVpnEditorPluginInterface *iface_class) -{ - /* interface implementation */ - iface_class->get_editor = get_editor; - iface_class->get_capabilities = get_capabilities; - /* TODO: implement delete_connection to purge associated secrets */ -} - - -G_MODULE_EXPORT NMVpnEditorPlugin * -nm_vpn_editor_plugin_factory (GError **error) -{ if (error) g_return_val_if_fail (*error == NULL, NULL); - return g_object_new (STRONGSWAN_TYPE_PLUGIN_UI, NULL); + object = 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 ((StrongswanPluginUiWidget*)object); + priv->builder = gtk_builder_new (); + + gtk_builder_set_translation_domain (priv->builder, GETTEXT_PACKAGE); + + if (!gtk_builder_add_from_resource (priv->builder, STRONGSWAN_UI_RESOURCE, error)) { + g_warning ("Couldn't load builder file: %s", + error && *error ? (*error)->message : "(unknown)"); + g_object_unref (object); + return NULL; + } + + priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "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; } diff --git a/src/frontends/gnome/properties/nm-strongswan.h b/src/frontends/gnome/properties/nm-strongswan.h index 629fbd439..2068609a8 100644 --- a/src/frontends/gnome/properties/nm-strongswan.h +++ b/src/frontends/gnome/properties/nm-strongswan.h @@ -31,27 +31,6 @@ typedef enum #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)) @@ -72,5 +51,6 @@ struct _StrongswanPluginUiWidgetClass { GType strongswan_plugin_ui_widget_get_type (void); -#endif /* _NM_STRONGSWAN_H_ */ +NMVpnEditor *strongswan_editor_new (NMConnection *connection, GError **error); +#endif /* _NM_STRONGSWAN_H_ */