diff options
author | Guido Günther <agx@sigxcpu.org> | 2016-03-13 13:09:26 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2016-03-13 13:09:26 +0100 |
commit | 42df2073982d4b56c3a091eb575bccea0b989c32 (patch) | |
tree | c031d90e705acf68d0e73f68dc14b6295861b942 | |
parent | 903e67bf8a568cff7ef826defca37a05f932eafb (diff) | |
parent | d9619973de807f74da4fd595b7719385a6dcfc93 (diff) |
Merge tag 'v1.1.0' into debian/sid
Release network-manager-iodine 1.1.0
-rw-r--r-- | Makefile.am | 11 | ||||
-rw-r--r-- | auth-dialog/Makefile.am | 11 | ||||
-rw-r--r-- | auth-dialog/main.c | 12 | ||||
-rw-r--r-- | configure.ac | 45 | ||||
-rw-r--r-- | nm-iodine-service.name.in | 3 | ||||
-rw-r--r-- | po/LINGUAS | 5 | ||||
-rw-r--r-- | po/bs.po | 110 | ||||
-rw-r--r-- | po/ca.po | 107 | ||||
-rw-r--r-- | po/de.po | 43 | ||||
-rw-r--r-- | po/pl.po | 61 | ||||
-rw-r--r-- | po/pt.po | 110 | ||||
-rw-r--r-- | po/sv.po | 110 | ||||
-rw-r--r-- | po/tr.po | 111 | ||||
-rw-r--r-- | properties/Makefile.am | 46 | ||||
-rw-r--r-- | properties/nm-iodine.c | 427 | ||||
-rw-r--r-- | properties/nm-iodine.h | 58 | ||||
-rw-r--r-- | src/Makefile.am | 14 | ||||
-rw-r--r-- | src/nm-iodine-service-defines.h | 33 | ||||
-rw-r--r-- | src/nm-iodine-service.c | 302 | ||||
-rw-r--r-- | src/nm-iodine-service.h | 32 |
20 files changed, 1079 insertions, 572 deletions
diff --git a/Makefile.am b/Makefile.am index 9b35207..24174e0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,11 +13,18 @@ endif dbusservicedir = $(sysconfdir)/dbus-1/system.d dbusservice_DATA = nm-iodine-service.conf -nmvpnservicedir = $(sysconfdir)/NetworkManager/VPN +nmvpnservicedir = $(NM_VPN_SERVICE_DIR) nmvpnservice_DATA = nm-iodine-service.name +if WITH_LIBNM_GLIB +nmvpnoldservicedir = $(sysconfdir)/NetworkManager/VPN +nmvpnoldservice_DATA = nm-iodine-service.name +endif + nm-iodine-service.name: $(srcdir)/nm-iodine-service.name.in - sed -e 's|[@]LIBEXECDIR[@]|$(libexecdir)|g' $< >$@ + sed -e 's|[@]LIBEXECDIR[@]|$(libexecdir)|g' \ + -e 's|[@]PLUGINDIR[@]|$(libdir)/NetworkManager|g' \ + $< >$@ DISTCHECK_CONFIGURE_FLAGS = --enable-more-warnings=yes diff --git a/auth-dialog/Makefile.am b/auth-dialog/Makefile.am index 2f26959..b9404c5 100644 --- a/auth-dialog/Makefile.am +++ b/auth-dialog/Makefile.am @@ -1,13 +1,10 @@ -INCLUDES = -I${top_srcdir} - libexec_PROGRAMS = nm-iodine-auth-dialog nm_iodine_auth_dialog_CPPFLAGS = \ - $(NM_CFLAGS) \ - $(GTHREAD_CFLAGS) \ $(GTK_CFLAGS) \ $(LIBSECRET_CFLAGS) \ - $(NMGTK_CFLAGS) \ + $(LIBNM_CFLAGS) \ + $(LIBNMA_CFLAGS) \ -DICONDIR=\""$(datadir)/pixmaps"\" \ -DBINDIR=\""$(bindir)"\" \ -DG_DISABLE_DEPRECATED \ @@ -22,8 +19,8 @@ nm_iodine_auth_dialog_SOURCES = \ nm_iodine_auth_dialog_LDADD = \ $(GTK_LIBS) \ - $(NM_LIBS) \ - $(NMGTK_LIBS) \ + $(LIBNM_LIBS) \ + $(LIBNMA_LIBS) \ $(LIBSECRET_LIBS) CLEANFILES = *~ diff --git a/auth-dialog/main.c b/auth-dialog/main.c index f482cf0..56d26dc 100644 --- a/auth-dialog/main.c +++ b/auth-dialog/main.c @@ -34,11 +34,11 @@ #define SECRET_API_SUBJECT_TO_CHANGE #include <libsecret/secret.h> -#include <nm-setting-vpn.h> -#include <nm-vpn-plugin-utils.h> -#include <nm-vpn-password-dialog.h> +#include <NetworkManager.h> +#include <nm-vpn-service-plugin.h> +#include <nma-vpn-password-dialog.h> -#include "src/nm-iodine-service.h" +#include "../src/nm-iodine-service-defines.h" #define KEYRING_UUID_TAG "connection-uuid" #define KEYRING_SN_TAG "setting-name" @@ -292,13 +292,13 @@ main (int argc, char *argv[]) g_option_context_parse (context, &argc, &argv, NULL); g_option_context_free (context); - if (!nm_vpn_plugin_utils_read_vpn_details (0, &data, &secrets)) { + if (!nm_vpn_service_plugin_read_vpn_details (0, &data, &secrets)) { fprintf (stderr, "Failed to read '%s' (%s) data and secrets from stdin.\n", vpn_name, vpn_uuid); return 1; } - nm_vpn_plugin_utils_get_secret_flags (secrets, NM_IODINE_KEY_PASSWORD, &pw_flags); + nm_vpn_service_plugin_get_secret_flags (secrets, NM_IODINE_KEY_PASSWORD, &pw_flags); if (!get_secrets (vpn_uuid, vpn_name, retry, allow_interaction, external_ui_mode, g_hash_table_lookup (secrets, NM_IODINE_KEY_PASSWORD), diff --git a/configure.ac b/configure.ac index fb146d9..8596102 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ(2.52) -AC_INIT(NetworkManager-iodine, 0.0.5, agx@sigxcpu.org, NetworkManager-iodine) +AC_INIT(NetworkManager-iodine, 1.1.0, agx@sigxcpu.org, NetworkManager-iodine) AM_INIT_AUTOMAKE([subdir-objects no-dist-gzip dist-xz]) AM_MAINTAINER_MODE @@ -45,6 +45,9 @@ AM_CONDITIONAL(WITH_GNOME, test x"$with_gnome" != xno) AC_ARG_WITH(authdlg, AS_HELP_STRING([--without-authdlg], [Build NetworkManager-iodine without authentication dialog])) AM_CONDITIONAL(WITH_AUTHDLG, test x"$with_authdlg" != xno) +AC_ARG_WITH(libnm-glib, AS_HELP_STRING([--without-libnm-glib], [Build NetworkManager-iodine without libnm-glib comatibility])) +AM_CONDITIONAL(WITH_LIBNM_GLIB, test x"$with_libnm_glib" != xno) + GETTEXT_PACKAGE=NetworkManager-iodine AC_SUBST(GETTEXT_PACKAGE) AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package]) @@ -52,37 +55,31 @@ 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.74) -AC_SUBST(DBUS_CFLAGS) -AC_SUBST(DBUS_LIBS) - if test x"$with_gnome" != xno; then gtk3_req=2.91.4 PKG_CHECK_MODULES(GTK, gtk+-3.0 > $gtk3_req, , [PKG_CHECK_MODULES(GTK, gtk+-2.0 > $gtk2_req)]) - AC_SUBST(GTK_CFLAGS) - AC_SUBST(GTK_LIBS) + PKG_CHECK_MODULES(LIBNMA, libnma >= 1.1.0) PKG_CHECK_MODULES(LIBSECRET, libsecret-1) - AC_SUBST(LIBSECRET_CFLAGS) - AC_SUBST(LIBSECRET_LIBS) + + if test x"$with_libnm_glib" != xno; then + PKG_CHECK_MODULES(LIBNM_GTK, libnm-gtk >= 0.9.9.0) + PKG_CHECK_MODULES(LIBNM_GLIB, + NetworkManager >= 1.1.0 + libnm-util >= 1.1.0 + libnm-glib >= 1.1.0 + libnm-glib-vpn >= 1.1.0) + fi + fi -PKG_CHECK_MODULES(NM, - NetworkManager >= 0.9.2 - libnm-util >= 0.9.2 - libnm-glib >= 0.9.2 - libnm-glib-vpn >= 0.9.2) -AC_SUBST(NM_CFLAGS) -AC_SUBST(NM_LIBS) - -PKG_CHECK_MODULES(NMGTK, libnm-gtk >= 0.9.9.0) -AC_SUBST(NMGTK_CFLAGS) -AC_SUBST(NMGTK_LIBS) +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" + +NM_VPN_SERVICE_DIR=`$PKG_CONFIG pkg-config --define-variable prefix='\${prefix}' --variable vpnservicedir libnm` +AC_SUBST(NM_VPN_SERVICE_DIR) NM_COMPILER_WARNINGS diff --git a/nm-iodine-service.name.in b/nm-iodine-service.name.in index e17f938..4061b43 100644 --- a/nm-iodine-service.name.in +++ b/nm-iodine-service.name.in @@ -3,6 +3,9 @@ name=iodine service=org.freedesktop.NetworkManager.iodine program=@LIBEXECDIR@/nm-iodine-service +[libnm] +plugin=@PLUGINDIR@/libnm-vpn-plugin-iodine.so + [GNOME] auth-dialog=nm-iodine-auth-dialog properties=libnm-iodine-properties @@ -1,4 +1,6 @@ # please keep this list sorted alphabetically +bs +ca cs de el @@ -11,7 +13,10 @@ lv lt pa pl +pt pt_BR sl sr sr@latin +sv +tr diff --git a/po/bs.po b/po/bs.po new file mode 100644 index 0000000..b534631 --- /dev/null +++ b/po/bs.po @@ -0,0 +1,110 @@ +# Bosnian translation for bosnianuniversetranslation +# Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013 +# This file is distributed under the same license as the bosnianuniversetranslation package. +# FIRST AUTHOR <EMAIL@ADDRESS>, 2013. +# +msgid "" +msgstr "" +"Project-Id-Version: bosnianuniversetranslation\n" +"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?" +"product=network-manager-iodine&keywords=I18N+L10N&component=general\n" +"POT-Creation-Date: 2015-02-26 23:32+0000\n" +"PO-Revision-Date: 2015-02-05 00:33+0000\n" +"Last-Translator: Samir Ribić <Unknown>\n" +"Language-Team: Bosnian <bs@li.org>\n" +"Language: bs\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2015-02-05 06:43+0000\n" +"X-Generator: Launchpad (build 17331)\n" + +#: ../auth-dialog/main.c:169 +#, c-format +msgid "You need to authenticate to access the Virtual Private Network '%s'." +msgstr "" +"Trebate provjeriti atutentičnost za pristup virtuelnoj privatnoj mreži '%s'." + +#: ../auth-dialog/main.c:182 ../auth-dialog/main.c:205 +msgid "Authenticate VPN" +msgstr "Autentificiraj VPN" + +#: ../auth-dialog/main.c:185 +msgid "Password:" +msgstr "Lozinka:" + +#: ../properties/nm-iodine.c:46 +msgid "Iodine DNS Tunnel" +msgstr "Jodine DNS tunel" + +#: ../properties/nm-iodine.c:47 +msgid "Tunnel connections via DNS." +msgstr "Tunelske veze putem DNS-a." + +#: ../properties/nm-iodine-dialog.ui.h:1 +msgid "Saved" +msgstr "Snimljeno" + +#: ../properties/nm-iodine-dialog.ui.h:2 +msgid "Always ask" +msgstr "Uvijek pitaj" + +#: ../properties/nm-iodine-dialog.ui.h:3 +msgid "General" +msgstr "Opšte" + +#: ../properties/nm-iodine-dialog.ui.h:4 +msgid "_Toplevel Domain:" +msgstr "_Domen najvišeg nivoa:" + +#: ../properties/nm-iodine-dialog.ui.h:5 +msgid "Optional" +msgstr "Opciono" + +#: ../properties/nm-iodine-dialog.ui.h:6 +msgid "_Nameserver:" +msgstr "_Server naziva:" + +#: ../properties/nm-iodine-dialog.ui.h:7 +msgid "_Password:" +msgstr "_Lozinka:" + +#: ../properties/nm-iodine-dialog.ui.h:8 +msgid "_Fragment Size:" +msgstr "_Veličina odlomka:" + +#: ../properties/nm-iodine-dialog.ui.h:9 +msgid "Show password" +msgstr "Prikaži lozinku" + +#: ../src/nm-iodine-service.c:131 +#, c-format +msgid "invalid integer property '%s' or out of range [%d -> %d]" +msgstr "neispravno svojstvo cijelog broja „%s“ ili je van opsega [%d —> %d]" + +#: ../src/nm-iodine-service.c:142 +#, c-format +msgid "invalid boolean property '%s' (not yes or no)" +msgstr "nevažeće bulovo svojstvo '%s' (nije da ili ne)" + +#: ../src/nm-iodine-service.c:149 +#, c-format +msgid "unhandled property '%s' type %s" +msgstr "neobrađeno svojstvo '%s' tipa %s" + +#: ../src/nm-iodine-service.c:163 +#, c-format +msgid "property '%s' invalid or not supported" +msgstr "svojstvo '%s' nevažeće ili nije podržano" + +#: ../src/nm-iodine-service.c:179 +msgid "No VPN configuration options." +msgstr "Nema VPN konfiguracijskih opcija." + +#: ../src/nm-iodine-service.c:198 +msgid "No VPN secrets!" +msgstr "Nema VPN tajni!" + +#: ../src/nm-iodine-service.c:483 +msgid "Could not find iodine binary." +msgstr "Ne mogu da pronađem jodine izvršni." diff --git a/po/ca.po b/po/ca.po new file mode 100644 index 0000000..e4c5fb1 --- /dev/null +++ b/po/ca.po @@ -0,0 +1,107 @@ +# Catalan translation for network-manager-iodine. +# Copyright (C) 2016 network-manager-iodine's COPYRIGHT HOLDER +# This file is distributed under the same license as the network-manager-iodine package. +# Walter Garcia-Fontes <walter.garcia@upf.edu>, 2016. +# +msgid "" +msgstr "" +"Project-Id-Version: network-manager-iodine master\n" +"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?" +"product=network-manager-iodine&keywords=I18N+L10N&component=general\n" +"POT-Creation-Date: 2016-01-06 01:57+0000\n" +"PO-Revision-Date: 2016-01-06 08:56+0100\n" +"Last-Translator: Walter Garcia-Fontes <walter.garcia@upf.edu>\n" +"Language-Team: Catalan <gnome@llistes.softcatala.org>\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../auth-dialog/main.c:169 +#, c-format +msgid "You need to authenticate to access the Virtual Private Network '%s'." +msgstr "Heu d'autentificar-vos per accedir la xarxa privada virtual «%s»." + +#: ../auth-dialog/main.c:182 ../auth-dialog/main.c:205 +msgid "Authenticate VPN" +msgstr "Autentifica la VPN" + +#: ../auth-dialog/main.c:185 +msgid "Password:" +msgstr "Contrasenya:" + +#: ../properties/nm-iodine.c:44 +msgid "Iodine DNS Tunnel" +msgstr "Túnel DNS Iodine" + +#: ../properties/nm-iodine.c:45 +msgid "Tunnel connections via DNS." +msgstr "Connexions de túnel a través de DNS." + +#: ../properties/nm-iodine-dialog.ui.h:1 +msgid "Saved" +msgstr "Desat" + +#: ../properties/nm-iodine-dialog.ui.h:2 +msgid "Always ask" +msgstr "Pregunta sempre" + +#: ../properties/nm-iodine-dialog.ui.h:3 +msgid "General" +msgstr "General" + +#: ../properties/nm-iodine-dialog.ui.h:4 +msgid "_Toplevel Domain:" +msgstr "Domini de nivell _superior:" + +#: ../properties/nm-iodine-dialog.ui.h:5 +msgid "Optional" +msgstr "Opcional" + +#: ../properties/nm-iodine-dialog.ui.h:6 +msgid "_Nameserver:" +msgstr "Servidor de _noms:" + +#: ../properties/nm-iodine-dialog.ui.h:7 +msgid "_Password:" +msgstr "_Contrasenya:" + +#: ../properties/nm-iodine-dialog.ui.h:8 +msgid "_Fragment Size:" +msgstr "Mida del _fragment:" + +#: ../properties/nm-iodine-dialog.ui.h:9 +msgid "Show password" +msgstr "Mostra la contrasenya" + +#: ../src/nm-iodine-service.c:131 +#, c-format +msgid "invalid integer property '%s' or out of range [%d -> %d]" +msgstr "propietat d'enter «%s» no vàlida o fora de rang [%d -> %d]" + +#: ../src/nm-iodine-service.c:142 +#, c-format +msgid "invalid boolean property '%s' (not yes or no)" +msgstr "propietat booleana «%s» no vàlida (no és sí o no)" + +#: ../src/nm-iodine-service.c:149 +#, c-format +msgid "unhandled property '%s' type %s" +msgstr "propietat «%s» o gestionada de tipus %s" + +#: ../src/nm-iodine-service.c:163 +#, c-format +msgid "property '%s' invalid or not supported" +msgstr "propietat «%s» no vàlida o sense suport" + +#: ../src/nm-iodine-service.c:179 +msgid "No VPN configuration options." +msgstr "No hi ha opcions de configuració de la VPN" + +#: ../src/nm-iodine-service.c:198 +msgid "No VPN secrets!" +msgstr "No hi ha secrets de la VPN!" + +#: ../src/nm-iodine-service.c:480 +msgid "Could not find iodine binary." +msgstr "No s'ha pogut trobar el binari iodine." @@ -2,51 +2,39 @@ # Copyright (C) 2013 network-manager-iodine's COPYRIGHT HOLDER # This file is distributed under the same license as the network-manager-iodine package. # Christian Kirbach <Christian.Kirbach@gmail.com>, 2013. +# Mario Blättermann <mario.blaettermann@gmail.com>, 2016. # msgid "" msgstr "" "Project-Id-Version: network-manager-iodine master\n" "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?" "product=network-manager-iodine&keywords=I18N+L10N&component=general\n" -"POT-Creation-Date: 2013-05-11 15:04+0000\n" -"PO-Revision-Date: 2013-06-04 16:44+0100\n" -"Last-Translator: Christian Kirbach <christian.kirbach@gmail.com>\n" +"POT-Creation-Date: 2014-10-12 11:29+0000\n" +"PO-Revision-Date: 2016-01-01 21:58+0100\n" +"Last-Translator: Mario Blättermann <mario.blaettermann@gmail.com>\n" "Language-Team: German <gnome-de@gnome.org>\n" "Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Poedit 1.5.5\n" +"X-Generator: Poedit 1.8.6\n" -#: ../auth-dialog/main.c:152 -#, fuzzy, c-format +#: ../auth-dialog/main.c:169 +#, c-format msgid "You need to authenticate to access the Virtual Private Network '%s'." msgstr "" -"Sie müssen sich für den Zugriff auf das virtuelle private Netz %s " +"Sie müssen sich für den Zugriff auf das Virtuelle Private Netz %s " "legitimieren." -#. Otherwise, we have no saved password, or the password flags indicated -#. * that the password should never be saved. -#. -#: ../auth-dialog/main.c:165 ../auth-dialog/main.c:188 -#, fuzzy +#: ../auth-dialog/main.c:182 ../auth-dialog/main.c:205 msgid "Authenticate VPN" -msgstr "Für VPN authentifizieren" +msgstr "VPN legitimieren" -#: ../auth-dialog/main.c:168 +#: ../auth-dialog/main.c:185 msgid "Password:" msgstr "Passwort:" -#: ../auth-dialog/vpn-password-dialog.c:90 -#: ../properties/nm-iodine-dialog.ui.h:7 -msgid "_Password:" -msgstr "_Passwort:" - -#: ../auth-dialog/vpn-password-dialog.c:223 -msgid "Sh_ow passwords" -msgstr "Passwörter _zeigen" - #: ../properties/nm-iodine.c:46 msgid "Iodine DNS Tunnel" msgstr "Iodine DNS-Tunnel" @@ -77,7 +65,11 @@ msgstr "Optional" #: ../properties/nm-iodine-dialog.ui.h:6 msgid "_Nameserver:" -msgstr "" +msgstr "_Nameserver:" + +#: ../properties/nm-iodine-dialog.ui.h:7 +msgid "_Password:" +msgstr "_Passwort:" #: ../properties/nm-iodine-dialog.ui.h:8 msgid "_Fragment Size:" @@ -119,3 +111,6 @@ msgstr "Keine VPN-Geheimnisse!" #: ../src/nm-iodine-service.c:483 msgid "Could not find iodine binary." msgstr "iodine-Binärdatei konnte nicht gefunden werden." + +#~ msgid "Sh_ow passwords" +#~ msgstr "Passwörter _zeigen" @@ -4,14 +4,14 @@ # pomóc w jego rozwijaniu i pielęgnowaniu, napisz do nas: # gnomepl@aviary.pl # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -# Piotr Drąg <piotrdrag@gmail.com>, 2012-2013. -# Aviary.pl <gnomepl@aviary.pl>, 2012-2013. +# Piotr Drąg <piotrdrag@gmail.com>, 2012-2015. +# Aviary.pl <gnomepl@aviary.pl>, 2012-2015. msgid "" msgstr "" "Project-Id-Version: network-manager-iodine\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-11-07 00:20+0100\n" -"PO-Revision-Date: 2013-11-07 00:21+0100\n" +"POT-Creation-Date: 2015-08-30 17:23+0200\n" +"PO-Revision-Date: 2015-08-30 17:24+0200\n" "Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n" "Language-Team: Polish <gnomepl@aviary.pl>\n" "Language: pl\n" @@ -23,50 +23,26 @@ msgstr "" "X-Poedit-Language: Polish\n" "X-Poedit-Country: Poland\n" -#: ../auth-dialog/main.c:152 +#: ../auth-dialog/main.c:169 #, c-format msgid "You need to authenticate to access the Virtual Private Network '%s'." msgstr "" -"Aby uzyskać dostęp do wirtualnej sieci prywatnej \"%s\", należy się " +"Aby uzyskać dostęp do wirtualnej sieci prywatnej „%s”, należy się " "uwierzytelnić." -#. Otherwise, we have no saved password, or the password flags indicated -#. * that the password should never be saved. -#. -#: ../auth-dialog/main.c:165 ../auth-dialog/main.c:188 +#: ../auth-dialog/main.c:182 ../auth-dialog/main.c:205 msgid "Authenticate VPN" msgstr "Uwierzytelnianie VPN" -#: ../auth-dialog/main.c:168 +#: ../auth-dialog/main.c:185 msgid "Password:" msgstr "Hasło:" -#: ../auth-dialog/vpn-password-dialog.c:90 -#: ../properties/nm-iodine-dialog.ui.h:7 -msgid "_Password:" -msgstr "_Hasło:" - -#: ../auth-dialog/vpn-password-dialog.c:187 -msgid "_Cancel" -msgstr "_Anuluj" - -#: ../auth-dialog/vpn-password-dialog.c:188 -msgid "_Ok" -msgstr "_OK" - -#: ../auth-dialog/vpn-password-dialog.c:223 -msgid "Sh_ow passwords" -msgstr "Wyświ_etlanie haseł" - -#: ../auth-dialog/vpn-password-dialog.c:248 -msgid "dialog-password" -msgstr "Okno dialogowe hasła" - -#: ../properties/nm-iodine.c:46 +#: ../properties/nm-iodine.c:44 msgid "Iodine DNS Tunnel" msgstr "Tunel DNS Iodine" -#: ../properties/nm-iodine.c:47 +#: ../properties/nm-iodine.c:45 msgid "Tunnel connections via DNS." msgstr "Połączenia tunelowe przez DNS." @@ -94,6 +70,10 @@ msgstr "Opcjonalne" msgid "_Nameserver:" msgstr "Serwer _nazw:" +#: ../properties/nm-iodine-dialog.ui.h:7 +msgid "_Password:" +msgstr "_Hasło:" + #: ../properties/nm-iodine-dialog.ui.h:8 msgid "_Fragment Size:" msgstr "_Rozmiar fragmentu:" @@ -106,25 +86,24 @@ msgstr "Wyświetlanie hasła" #, c-format msgid "invalid integer property '%s' or out of range [%d -> %d]" msgstr "" -"nieprawidłowa własność liczby całkowitej \"%s\" lub jest poza zakresem [%d -" -"> %d]" +"nieprawidłowa własność liczby całkowitej „%s” lub jest poza zakresem [%d -> " +"%d]" #: ../src/nm-iodine-service.c:142 #, c-format msgid "invalid boolean property '%s' (not yes or no)" msgstr "" -"nieprawidłowa własność zmiennej logicznej \"%s\" (nie wynosi \"yes\" lub \"no" -"\")" +"nieprawidłowa własność zmiennej logicznej „%s” (nie wynosi „yes” lub „no”)" #: ../src/nm-iodine-service.c:149 #, c-format msgid "unhandled property '%s' type %s" -msgstr "nieobsługiwana własność \"%s\" typu \"%s\"" +msgstr "nieobsługiwana własność „%s” typu „%s”" #: ../src/nm-iodine-service.c:163 #, c-format msgid "property '%s' invalid or not supported" -msgstr "własność \"%s\" jest nieprawidłowa lub nieobsługiwana" +msgstr "własność „%s” jest nieprawidłowa lub nieobsługiwana" #: ../src/nm-iodine-service.c:179 msgid "No VPN configuration options." @@ -134,6 +113,6 @@ msgstr "Brak opcji konfiguracji VPN." msgid "No VPN secrets!" msgstr "Brak haseł VPN." -#: ../src/nm-iodine-service.c:483 +#: ../src/nm-iodine-service.c:480 msgid "Could not find iodine binary." msgstr "Nie można odnaleźć pliku binarnego iodine." diff --git a/po/pt.po b/po/pt.po new file mode 100644 index 0000000..5287647 --- /dev/null +++ b/po/pt.po @@ -0,0 +1,110 @@ +# Portuguese translation for network-manager-iodine. +# Copyright (C) 2015 network-manager-iodine's COPYRIGHT HOLDER +# This file is distributed under the same license as the network-manager-iodine package. +# Tiago S. <almosthumane@portugalmail.pt>, 2015. +# Pedro Albuquerque <palbuquerque73@gmail.com>, 2015. +msgid "" +msgstr "" +"Project-Id-Version: network-manager-iodine master\n" +"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?product" +"=network-manager-iodine&keywords=I18N+L10N&component=general\n" +"POT-Creation-Date: 2015-10-31 01:46+0000\n" +"PO-Revision-Date: 2015-11-08 08:39+0100\n" +"Last-Translator: Pedro Albuquerque <palbuquerque73@gmail.com>\n" +"Language-Team: Pedro Albuquerque\n" +"Language: pt\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Virtaal 0.7.1\n" +"X-Project-Style: gnome\n" + +#: ../auth-dialog/main.c:169 +#, c-format +msgid "You need to authenticate to access the Virtual Private Network '%s'." +msgstr "Tem de se autenticar para aceder à rede privada virtual(VPN) '%s'." + +#: ../auth-dialog/main.c:182 ../auth-dialog/main.c:205 +msgid "Authenticate VPN" +msgstr "Autenticação VPN" + +#: ../auth-dialog/main.c:185 +msgid "Password:" +msgstr "Senha:" + +#: ../properties/nm-iodine.c:44 +msgid "Iodine DNS Tunnel" +msgstr "Túnel DNS Iodine" + +#: ../properties/nm-iodine.c:45 +msgid "Tunnel connections via DNS." +msgstr "Ligações em túnel via DNS." + +#: ../properties/nm-iodine-dialog.ui.h:1 +msgid "Saved" +msgstr "Gravado" + +#: ../properties/nm-iodine-dialog.ui.h:2 +msgid "Always ask" +msgstr "Perguntar sempre" + +#: ../properties/nm-iodine-dialog.ui.h:3 +msgid "General" +msgstr "Geral" + +#: ../properties/nm-iodine-dialog.ui.h:4 +msgid "_Toplevel Domain:" +msgstr "Domínio de _Topo:" + +#: ../properties/nm-iodine-dialog.ui.h:5 +msgid "Optional" +msgstr "Opcional" + +#: ../properties/nm-iodine-dialog.ui.h:6 +msgid "_Nameserver:" +msgstr "Servidor de _Nomes:" + +#: ../properties/nm-iodine-dialog.ui.h:7 +msgid "_Password:" +msgstr "_Senha:" + +#: ../properties/nm-iodine-dialog.ui.h:8 +msgid "_Fragment Size:" +msgstr "Tamanho do _Fragmento:" + +#: ../properties/nm-iodine-dialog.ui.h:9 +msgid "Show password" +msgstr "Mostrar senha" + +#: ../src/nm-iodine-service.c:131 +#, c-format +msgid "invalid integer property '%s' or out of range [%d -> %d]" +msgstr "propriedade inteira \"%s\" inválida ou fora dos limites [%d -> %d]" + +#: ../src/nm-iodine-service.c:142 +#, c-format +msgid "invalid boolean property '%s' (not yes or no)" +msgstr "propriedade booliana \"%s\" inválida (não é sim ou não)" + +#: ../src/nm-iodine-service.c:149 +#, c-format +msgid "unhandled property '%s' type %s" +msgstr "propriedade não gerida \"%s\" tipo %s" + +#: ../src/nm-iodine-service.c:163 +#, c-format +msgid "property '%s' invalid or not supported" +msgstr "propriedade \"%s\" inválida ou não suportada" + +#: ../src/nm-iodine-service.c:179 +msgid "No VPN configuration options." +msgstr "Sem opções de configuração VPN." + +#: ../src/nm-iodine-service.c:198 +msgid "No VPN secrets!" +msgstr "Sem segredos VPN!" + +#: ../src/nm-iodine-service.c:480 +msgid "Could not find iodine binary." +msgstr "Impossível encontrar um binário iodine." diff --git a/po/sv.po b/po/sv.po new file mode 100644 index 0000000..2905799 --- /dev/null +++ b/po/sv.po @@ -0,0 +1,110 @@ +# Swedish translation for network-manager-iodine. +# Copyright © 2015 network-manager-iodine's COPYRIGHT HOLDER +# This file is distributed under the same license as the network-manager-iodine package. +# Josef Andersson <josef.andersson@fripost.org>, 2015. +msgid "" +msgstr "" +"Project-Id-Version: network-manager-iodine master\n" +"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?" +"product=network-manager-iodine&keywords=I18N+L10N&component=general\n" +"POT-Creation-Date: 2015-06-29 11:02+0000\n" +"PO-Revision-Date: 2015-06-28 20:20+0100\n" +"Last-Translator: Josef Andersson <josef.andersson@fripost.org>\n" +"Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n" +"Language: sv\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Virtaal 0.7.1\n" +"X-Project-Style: gnome\n" + +#: ../auth-dialog/main.c:169 +#, c-format +msgid "You need to authenticate to access the Virtual Private Network '%s'." +msgstr "" +"Du behöver autentisera för att komma åt Virtuella Privata Nätverket ”%s”." + +#: ../auth-dialog/main.c:182 ../auth-dialog/main.c:205 +msgid "Authenticate VPN" +msgstr "Autentisera VPN" + +#: ../auth-dialog/main.c:185 +msgid "Password:" +msgstr "Lösenord:" + +#: ../properties/nm-iodine.c:44 +msgid "Iodine DNS Tunnel" +msgstr "Iodine DNS-tunnel" + +#: ../properties/nm-iodine.c:45 +msgid "Tunnel connections via DNS." +msgstr "Tunnelanslutning via DNS." + +#: ../properties/nm-iodine-dialog.ui.h:1 +msgid "Saved" +msgstr "Sparad" + +#: ../properties/nm-iodine-dialog.ui.h:2 +msgid "Always ask" +msgstr "Fråga alltid" + +#: ../properties/nm-iodine-dialog.ui.h:3 +msgid "General" +msgstr "Allmänt" + +#: ../properties/nm-iodine-dialog.ui.h:4 +msgid "_Toplevel Domain:" +msgstr "_Toppnivådomän:" + +#: ../properties/nm-iodine-dialog.ui.h:5 +msgid "Optional" +msgstr "Valfri" + +#: ../properties/nm-iodine-dialog.ui.h:6 +msgid "_Nameserver:" +msgstr "_Namnserver:" + +#: ../properties/nm-iodine-dialog.ui.h:7 +msgid "_Password:" +msgstr "_Lösenord:" + +#: ../properties/nm-iodine-dialog.ui.h:8 +msgid "_Fragment Size:" +msgstr "_Fragmentstorlek:" + +#: ../properties/nm-iodine-dialog.ui.h:9 +msgid "Show password" +msgstr "Visa lösenord" + +#: ../src/nm-iodine-service.c:131 +#, c-format +msgid "invalid integer property '%s' or out of range [%d -> %d]" +msgstr "ogiltig heltalsegenskap ”%s” eller utanför intervallet [%d -> %d]" + +#: ../src/nm-iodine-service.c:142 +#, c-format +msgid "invalid boolean property '%s' (not yes or no)" +msgstr "ogiltig boolesk egenskap ”%s” (varken ja eller nej)" + +#: ../src/nm-iodine-service.c:149 +#, c-format +msgid "unhandled property '%s' type %s" +msgstr "ohanterad egenskap ”%s” typ %s" + +#: ../src/nm-iodine-service.c:163 +#, c-format +msgid "property '%s' invalid or not supported" +msgstr "egenskapen ”%s” är ogiltig eller stöds ej" + +#: ../src/nm-iodine-service.c:179 +msgid "No VPN configuration options." +msgstr "Inga alternativ för VPN-konfiguration." + +#: ../src/nm-iodine-service.c:198 +msgid "No VPN secrets!" +msgstr "Inga VPN-hemligheter!" + +#: ../src/nm-iodine-service.c:480 +msgid "Could not find iodine binary." +msgstr "Kunde inte hitta iodine-binären." diff --git a/po/tr.po b/po/tr.po new file mode 100644 index 0000000..4bb8598 --- /dev/null +++ b/po/tr.po @@ -0,0 +1,111 @@ +# Turkish translation for network-manager-iodine. +# Copyright (C) 2014 network-manager-iodine's COPYRIGHT HOLDER +# This file is distributed under the same license as the network-manager-iodine package. +# Necdet Yücel <necdetyucel@gmail.com>, 2014. +# +msgid "" +msgstr "" +"Project-Id-Version: network-manager-iodine master\n" +"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?" +"product=network-manager-iodine&keywords=I18N+L10N&component=general\n" +"POT-Creation-Date: 2014-12-04 11:11+0000\n" +"PO-Revision-Date: 2014-12-01 22:29+0000\n" +"Last-Translator: Necdet Yücel <necdetyucel@gmail.com>\n" +"Language-Team: Turkish <gnome-turk@gnome.org>\n" +"Language: tr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Pootle 2.5.1.1\n" +"X-POOTLE-MTIME: 1417472997.000000\n" + +#: ../auth-dialog/main.c:169 +#, c-format +msgid "You need to authenticate to access the Virtual Private Network '%s'." +msgstr "" +"'%s' Sanal Özel Ağına erişmek için kimlik kanıtlaması yapmanız gerekir." + +#: ../auth-dialog/main.c:182 ../auth-dialog/main.c:205 +msgid "Authenticate VPN" +msgstr "VPN Kimlik Kanıtlaması" + +#: ../auth-dialog/main.c:185 +msgid "Password:" +msgstr "Parola:" + +#: ../properties/nm-iodine.c:46 +msgid "Iodine DNS Tunnel" +msgstr "Iodine DNS Tuneli" + +#: ../properties/nm-iodine.c:47 +msgid "Tunnel connections via DNS." +msgstr "Bağlantıları DNS ile tünelle." + +#: ../properties/nm-iodine-dialog.ui.h:1 +msgid "Saved" +msgstr "Kaydedildi" + +#: ../properties/nm-iodine-dialog.ui.h:2 +msgid "Always ask" +msgstr "Her zaman sor" + +#: ../properties/nm-iodine-dialog.ui.h:3 +msgid "General" +msgstr "Genel" + +#: ../properties/nm-iodine-dialog.ui.h:4 +msgid "_Toplevel Domain:" +msgstr "_Üst Düzey Alan:" + +#: ../properties/nm-iodine-dialog.ui.h:5 +msgid "Optional" +msgstr "İsteğe bağlı" + +#: ../properties/nm-iodine-dialog.ui.h:6 +msgid "_Nameserver:" +msgstr "_Alan Adı Sunucusu:" + +#: ../properties/nm-iodine-dialog.ui.h:7 +msgid "_Password:" +msgstr "_Parola:" + +#: ../properties/nm-iodine-dialog.ui.h:8 +msgid "_Fragment Size:" +msgstr "Parça _Boyutu:" + +#: ../properties/nm-iodine-dialog.ui.h:9 +msgid "Show password" +msgstr "Parolayı göster" + +#: ../src/nm-iodine-service.c:131 +#, c-format +msgid "invalid integer property '%s' or out of range [%d -> %d]" +msgstr "'%s' geçersiz bir tamsayı veya sınırların dışında [%d -> %d]" + +#: ../src/nm-iodine-service.c:142 +#, c-format +msgid "invalid boolean property '%s' (not yes or no)" +msgstr "'%s' geçersiz bir mantıksal sabit (evet veya hayır değil)" + +#: ../src/nm-iodine-service.c:149 +#, c-format +msgid "unhandled property '%s' type %s" +msgstr "tanınmayan özellik '%s' tür %s" + +#: ../src/nm-iodine-service.c:163 +#, c-format +msgid "property '%s' invalid or not supported" +msgstr "'%s' özelliği geçersiz veya desteklenmiyor" + +#: ../src/nm-iodine-service.c:179 +msgid "No VPN configuration options." +msgstr "VPN yapılandırma seçeneği bulunamadı." + +#: ../src/nm-iodine-service.c:198 +msgid "No VPN secrets!" +msgstr "VPN gizli bilgisi yok!" + +#: ../src/nm-iodine-service.c:483 +msgid "Could not find iodine binary." +msgstr "Iodine çalıştırılabilir dosyası bulunamadı." diff --git a/properties/Makefile.am b/properties/Makefile.am index 30e7529..6edc5bc 100644 --- a/properties/Makefile.am +++ b/properties/Makefile.am @@ -1,17 +1,22 @@ plugindir = $(libdir)/NetworkManager -plugin_LTLIBRARIES = libnm-iodine-properties.la +plugin_LTLIBRARIES = libnm-vpn-plugin-iodine.la +if WITH_LIBNM_GLIB +plugin_LTLIBRARIES += libnm-iodine-properties.la +endif -libnm_iodine_properties_la_SOURCES = \ - nm-iodine.c \ - nm-iodine.h +libnm_vpn_plugin_iodine_la_SOURCES = \ + nm-iodine.c \ + nm-iodine.h + +libnm_iodine_properties_la_SOURCES = \ + $(libnm_vpn_plugin_iodine_la_SOURCES) uidir = $(datadir)/gnome-vpn-properties/iodine ui_DATA = nm-iodine-dialog.ui -libnm_iodine_properties_la_CFLAGS = \ +common_CFLAGS = \ $(GTK_CFLAGS) \ - $(GCONF_CFLAGS) \ - $(NM_CFLAGS) \ + -I$(top_srcdir)/src \ -DICONDIR=\""$(datadir)/pixmaps"\" \ -DUIDIR=\""$(uidir)"\" \ -DG_DISABLE_DEPRECATED \ @@ -20,14 +25,31 @@ libnm_iodine_properties_la_CFLAGS = \ -DGNOMELOCALEDIR=\"$(datadir)/locale\" \ -DVERSION=\"$(VERSION)\" -libnm_iodine_properties_la_LIBADD = \ - $(GTK_LIBS) \ - $(GCONF_LIBS) \ - $(NM_LIBS) +libnm_vpn_plugin_iodine_la_CFLAGS = \ + $(LIBNM_CFLAGS) \ + $(LIBNMA_CFLAGS) \ + $(common_CFLAGS) + +libnm_iodine_properties_la_CFLAGS = \ + -DNM_IODINE_OLD \ + $(LIBNM_GLIB_CFLAGS) \ + $(common_CFLAGS) + +libnm_vpn_plugin_iodine_la_LIBADD = \ + $(GTK_LIBS) \ + $(LIBNMA_LIBS) \ + $(LIBNM_LIBS) -libnm_iodine_properties_la_LDFLAGS = \ +libnm_iodine_properties_la_LIBADD = \ + $(GTK_LIBS) \ + $(LIBNM_GLIB_LIBS) + +libnm_vpn_plugin_iodine_la_LDFLAGS = \ -avoid-version +libnm_iodine_properties_la_LDFLAGS = \ + $(libnm_vpn_plugin_iodine_la_LDFLAGS) + CLEANFILES = *.bak *~ EXTRA_DIST = \ diff --git a/properties/nm-iodine.c b/properties/nm-iodine.c index b1e7537..a0a51de 100644 --- a/properties/nm-iodine.c +++ b/properties/nm-iodine.c @@ -33,14 +33,28 @@ #include <string.h> #include <gtk/gtk.h> -#define NM_VPN_API_SUBJECT_TO_CHANGE - +#ifdef NM_IODINE_OLD +#define NM_VPN_LIBNM_COMPAT #include <nm-vpn-plugin-ui-interface.h> #include <nm-setting-vpn.h> #include <nm-setting-connection.h> #include <nm-setting-ip4-config.h> -#include "../src/nm-iodine-service.h" +#define nm_simple_connection_new nm_connection_new + +#define IODINE_EDITOR_PLUGIN_ERROR NM_SETTING_VPN_ERROR +#define IODINE_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY NM_SETTING_VPN_ERROR_INVALID_PROPERTY + +#else /* !NM_IODINE_OLD */ + +#include <NetworkManager.h> +#include <nma-ui-utils.h> + +#define IODINE_EDITOR_PLUGIN_ERROR NM_CONNECTION_ERROR +#define IODINE_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY NM_CONNECTION_ERROR_INVALID_PROPERTY +#endif + +#include "nm-iodine-service-defines.h" #include "nm-iodine.h" #define IODINE_PLUGIN_NAME _("Iodine DNS Tunnel") @@ -53,37 +67,60 @@ /************** plugin class **************/ -static void iodine_plugin_ui_interface_init (NMVpnPluginUiInterface - *iface_class); +enum { + PROP_0, + PROP_NAME, + PROP_DESC, + PROP_SERVICE +}; + +static void iodine_editor_plugin_interface_init (NMVpnEditorPluginInterface *iface_class); -G_DEFINE_TYPE_EXTENDED (IodinePluginUi, iodine_plugin_ui, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_INTERFACE, - iodine_plugin_ui_interface_init)) +G_DEFINE_TYPE_EXTENDED (IodineEditorPlugin, iodine_editor_plugin, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR_PLUGIN, + iodine_editor_plugin_interface_init)) /************** UI widget class **************/ -static void iodine_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface - *iface_class); +static void iodine_editor_interface_init (NMVpnEditorInterface *iface_class); -G_DEFINE_TYPE_EXTENDED (IodinePluginUiWidget, iodine_plugin_ui_widget,G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE, - iodine_plugin_ui_widget_interface_init)) +G_DEFINE_TYPE_EXTENDED (IodineEditor, iodine_editor,G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR, + iodine_editor_interface_init)) -#define IODINE_PLUGIN_UI_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), IODINE_TYPE_PLUGIN_UI_WIDGET, IodinePluginUiWidgetPrivate)) +#define IODINE_EDITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), IODINE_TYPE_EDITOR, IodineEditorPrivate)) typedef struct { GtkBuilder *builder; GtkWidget *widget; GtkSizeGroup *group; gboolean window_added; -} IodinePluginUiWidgetPrivate; +} IodineEditorPrivate; + +typedef enum { + NM_IODINE_IMPORT_EXPORT_ERROR_UNKNOWN = 0, + NM_IODINE_IMPORT_EXPORT_ERROR_NOT_IODINE, + NM_IODINE_IMPORT_EXPORT_ERROR_BAD_DATA, +} NMIodineImportError; + +#define NM_IODINE_IMPORT_EXPORT_ERROR nm_iodine_import_export_error_quark () + +static GQuark +nm_iodine_import_export_error_quark (void) +{ + static GQuark quark = 0; + + if (G_UNLIKELY (quark == 0)) + quark = g_quark_from_static_string ("nm-iodine-import-export-error-quark"); + return quark; +} static NMConnection * -import (NMVpnPluginUiInterface *iface, const char *path, GError **error) +import (NMVpnEditorPlugin *iface, const char *path, GError **error) { NMConnection *connection; NMSettingConnection *s_con; - NMSettingVPN *s_vpn; + NMSettingVpn *s_vpn; NMSettingIP4Config *s_ip4; GKeyFile *keyfile; GKeyFileFlags flags; @@ -94,22 +131,22 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error) if (!g_key_file_load_from_file (keyfile, path, flags, error)) { g_set_error (error, - 0, - 0, - "does not look like a %s VPN connection (parse failed)", - IODINE_PLUGIN_NAME); + NM_IODINE_IMPORT_EXPORT_ERROR, + NM_IODINE_IMPORT_EXPORT_ERROR_NOT_IODINE, + "does not look like a %s VPN connection (parse failed)", + IODINE_PLUGIN_NAME); return NULL; } - connection = nm_connection_new (); + connection = nm_simple_connection_new (); s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); nm_connection_add_setting (connection, NM_SETTING (s_con)); s_vpn = NM_SETTING_VPN (nm_setting_vpn_new ()); g_object_set (s_vpn, - NM_SETTING_VPN_SERVICE_TYPE, - NM_DBUS_SERVICE_IODINE, - NULL); + NM_SETTING_VPN_SERVICE_TYPE, + NM_DBUS_SERVICE_IODINE, + NULL); nm_connection_add_setting (connection, NM_SETTING (s_vpn)); s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ()); @@ -121,11 +158,11 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error) nm_setting_vpn_add_data_item (s_vpn, NM_IODINE_KEY_TOPDOMAIN, buf); } else { g_set_error (error, - 0, - 0, - "does not look like a %s VPN connection " - "(no top level domain)", - IODINE_PLUGIN_NAME); + NM_IODINE_IMPORT_EXPORT_ERROR, + NM_IODINE_IMPORT_EXPORT_ERROR_NOT_IODINE, + "does not look like a %s VPN connection " + "(no top level domain)", + IODINE_PLUGIN_NAME); g_object_unref (connection); return NULL; } @@ -150,13 +187,12 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error) } static gboolean -export (NMVpnPluginUiInterface *iface, +export (NMVpnEditorPlugin *iface, const char *path, NMConnection *connection, GError **error) { - NMSettingConnection *s_con; - NMSettingVPN *s_vpn; + NMSettingVpn *s_vpn; const char *value; const char *topdomain = NULL; const char *nameserver = NULL; @@ -166,22 +202,23 @@ export (NMVpnPluginUiInterface *iface, f = fopen (path, "w"); if (!f) { - g_set_error (error, 0, 0, "could not open file for writing"); + g_set_error (error, + NM_IODINE_IMPORT_EXPORT_ERROR, + NM_IODINE_IMPORT_EXPORT_ERROR_UNKNOWN, + "could not open file for writing"); return FALSE; } - s_con = NM_SETTING_CONNECTION (nm_connection_get_setting - (connection, NM_TYPE_SETTING_CONNECTION)); - - s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, - NM_TYPE_SETTING_VPN); + s_vpn = nm_connection_get_setting_vpn (connection); value = nm_setting_vpn_get_data_item (s_vpn, NM_IODINE_KEY_TOPDOMAIN); if (value && strlen (value)) topdomain = value; else { - g_set_error (error, 0, 0, - "connection was incomplete (missing top level domain)"); + g_set_error (error, + NM_IODINE_IMPORT_EXPORT_ERROR, + NM_IODINE_IMPORT_EXPORT_ERROR_UNKNOWN, + "connection was incomplete (missing top level domain)"); goto done; } @@ -194,15 +231,15 @@ export (NMVpnPluginUiInterface *iface, fragsize = value; fprintf (f, - "[iodine]\n" - "Description=%s\n" - "Topdomain=%s\n" - "Nameserver=%s\n" - "Fragsize=%s\n", - /* Description */ nm_setting_connection_get_id (s_con), - /* Topdomain */ topdomain, - /* Nameserver */ nameserver, - /* Fragsize */ fragsize); + "[iodine]\n" + "Description=%s\n" + "Topdomain=%s\n" + "Nameserver=%s\n" + "Fragsize=%s\n", + /* Description */ nm_connection_get_id (connection), + /* Topdomain */ topdomain, + /* Nameserver */ nameserver, + /* Fragsize */ fragsize); success = TRUE; @@ -211,58 +248,20 @@ done: return success; } -GQuark -iodine_plugin_ui_error_quark (void) -{ - static GQuark error_quark = 0; - - if (G_UNLIKELY (error_quark == 0)) - error_quark = g_quark_from_static_string ("iodine-plugin-ui-error-quark"); - - return error_quark; -} - -/* This should really be standard. */ -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -iodine_plugin_ui_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - /* Unknown error. */ - ENUM_ENTRY (IODINE_PLUGIN_UI_ERROR_UNKNOWN, - "UnknownError"), - /* The specified property was invalid. */ - ENUM_ENTRY (IODINE_PLUGIN_UI_ERROR_INVALID_PROPERTY, - "InvalidProperty"), - /* The specified property was missing and is required. */ - ENUM_ENTRY (IODINE_PLUGIN_UI_ERROR_MISSING_PROPERTY, - "MissingProperty"), - { 0, 0, 0 } - }; - etype = g_enum_register_static ("IodinePluginUiError", values); - } - return etype; -} - static gboolean -check_validity (IodinePluginUiWidget *self, GError **error) +check_validity (IodineEditor *self, GError **error) { - IodinePluginUiWidgetPrivate *priv = \ - IODINE_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + IodineEditorPrivate *priv = \ + IODINE_EDITOR_GET_PRIVATE (self); GtkWidget *widget; const char *str; - widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, - "topdomain_entry")); + widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "topdomain_entry")); str = gtk_entry_get_text (GTK_ENTRY (widget)); if (!str || !strlen (str)) { g_set_error (error, - IODINE_PLUGIN_UI_ERROR, - IODINE_PLUGIN_UI_ERROR_INVALID_PROPERTY, + IODINE_EDITOR_PLUGIN_ERROR, + IODINE_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY, NM_IODINE_KEY_TOPDOMAIN); return FALSE; } @@ -273,17 +272,17 @@ check_validity (IodinePluginUiWidget *self, GError **error) static void stuff_changed_cb (GtkWidget *widget, gpointer user_data) { - g_signal_emit_by_name (IODINE_PLUGIN_UI_WIDGET (user_data), "changed"); + g_signal_emit_by_name (IODINE_EDITOR (user_data), "changed"); } static void -setup_password_widget (IodinePluginUiWidget *self, +setup_password_widget (IodineEditor *self, const char *entry_name, - NMSettingVPN *s_vpn, + NMSettingVpn *s_vpn, const char *secret_name) { - IodinePluginUiWidgetPrivate *priv = \ - IODINE_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + IodineEditorPrivate *priv = \ + IODINE_EDITOR_GET_PRIVATE (self); NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE; GtkWidget *widget; @@ -301,32 +300,30 @@ setup_password_widget (IodinePluginUiWidget *self, value = nm_setting_vpn_get_secret (s_vpn, secret_name); gtk_entry_set_text (GTK_ENTRY (widget), value ? value : ""); nm_setting_get_secret_flags (NM_SETTING (s_vpn), - secret_name, - &secret_flags, - NULL); + secret_name, + &secret_flags, + NULL); } secret_flags &= ~(NM_SETTING_SECRET_FLAG_NOT_SAVED | - NM_SETTING_SECRET_FLAG_NOT_REQUIRED); + NM_SETTING_SECRET_FLAG_NOT_REQUIRED); g_object_set_data (G_OBJECT (widget), - "flags", - GUINT_TO_POINTER (secret_flags)); + "flags", + GUINT_TO_POINTER (secret_flags)); g_signal_connect (widget, "changed", G_CALLBACK (stuff_changed_cb), self); } static void -show_toggled_cb (GtkCheckButton *button, IodinePluginUiWidget *self) +show_toggled_cb (GtkCheckButton *button, IodineEditor *self) { - IodinePluginUiWidgetPrivate *priv = \ - IODINE_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + IodineEditorPrivate *priv = IODINE_EDITOR_GET_PRIVATE (self); GtkWidget *widget; gboolean visible; visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, - "password_entry")); + widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "password_entry")); g_assert (widget); gtk_entry_set_visibility (GTK_ENTRY (widget), visible); } @@ -334,13 +331,11 @@ show_toggled_cb (GtkCheckButton *button, IodinePluginUiWidget *self) static void pw_type_combo_changed_cb (GtkWidget *combo, gpointer user_data) { - IodinePluginUiWidget *self = IODINE_PLUGIN_UI_WIDGET (user_data); - IodinePluginUiWidgetPrivate *priv = \ - IODINE_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + IodineEditor *self = IODINE_EDITOR (user_data); + IodineEditorPrivate *priv = IODINE_EDITOR_GET_PRIVATE (self); GtkWidget *entry; - entry = GTK_WIDGET (gtk_builder_get_object (priv->builder, - "password_entry")); + entry = GTK_WIDGET (gtk_builder_get_object (priv->builder, "password_entry")); g_assert (entry); /* If the user chose "Not required", desensitize and clear the correct @@ -361,14 +356,13 @@ pw_type_combo_changed_cb (GtkWidget *combo, gpointer user_data) } static void -init_one_pw_combo (IodinePluginUiWidget *self, - NMSettingVPN *s_vpn, +init_one_pw_combo (IodineEditor *self, + NMSettingVpn *s_vpn, const char *combo_name, const char *secret_key, const char *entry_name) { - IodinePluginUiWidgetPrivate *priv = \ - IODINE_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + IodineEditorPrivate *priv = IODINE_EDITOR_GET_PRIVATE (self); int active = -1; GtkWidget *widget; GtkListStore *store; @@ -390,9 +384,9 @@ init_one_pw_combo (IodinePluginUiWidget *self, if (s_vpn) nm_setting_get_secret_flags (NM_SETTING (s_vpn), - secret_key, - &pw_flags, - NULL); + secret_key, + &pw_flags, + NULL); if ((active < 0) && !(pw_flags & NM_SETTING_SECRET_FLAG_NOT_SAVED) && !(pw_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED)) { @@ -407,33 +401,30 @@ init_one_pw_combo (IodinePluginUiWidget *self, widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, combo_name)); g_assert (widget); - gtk_combo_box_set_active (GTK_COMBO_BOX (widget), - active < 0 ? default_idx : active); + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), + active < 0 ? default_idx : active); pw_type_combo_changed_cb (widget, self); g_signal_connect (G_OBJECT (widget), - "changed", - G_CALLBACK (pw_type_combo_changed_cb), self); + "changed", + G_CALLBACK (pw_type_combo_changed_cb), self); } static gboolean -init_plugin_ui (IodinePluginUiWidget *self, - NMConnection *connection, - GError **error) +init_editor_plugin (IodineEditor *self, + NMConnection *connection, + GError **error) { - IodinePluginUiWidgetPrivate *priv = \ - IODINE_PLUGIN_UI_WIDGET_GET_PRIVATE (self); - NMSettingVPN *s_vpn; + IodineEditorPrivate *priv = IODINE_EDITOR_GET_PRIVATE (self); + NMSettingVpn *s_vpn; GtkWidget *widget; const char *value; - s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, - NM_TYPE_SETTING_VPN); + s_vpn = nm_connection_get_setting_vpn (connection); priv->group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, - "topdomain_entry")); + widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "topdomain_entry")); if (!widget) return FALSE; gtk_size_group_add_widget (priv->group, widget); @@ -443,11 +434,10 @@ init_plugin_ui (IodinePluginUiWidget *self, gtk_entry_set_text (GTK_ENTRY (widget), value); } g_signal_connect (G_OBJECT (widget), - "changed", - G_CALLBACK (stuff_changed_cb), self); + "changed", + G_CALLBACK (stuff_changed_cb), self); - widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, - "nameserver_entry")); + widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "nameserver_entry")); if (!widget) return FALSE; gtk_size_group_add_widget (priv->group, widget); @@ -457,11 +447,10 @@ init_plugin_ui (IodinePluginUiWidget *self, gtk_entry_set_text (GTK_ENTRY (widget), value); } g_signal_connect (G_OBJECT (widget), - "changed", - G_CALLBACK (stuff_changed_cb), self); + "changed", + G_CALLBACK (stuff_changed_cb), self); - widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, - "fragsize_entry")); + widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "fragsize_entry")); if (!widget) return FALSE; if (s_vpn) { @@ -470,19 +459,18 @@ init_plugin_ui (IodinePluginUiWidget *self, gtk_entry_set_text (GTK_ENTRY (widget), value); } g_signal_connect (G_OBJECT (widget), - "changed", - G_CALLBACK (stuff_changed_cb), self); + "changed", + G_CALLBACK (stuff_changed_cb), self); - widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, - "show_passwords_checkbutton")); + widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "show_passwords_checkbutton")); g_signal_connect (G_OBJECT (widget), "toggled", (GCallback) show_toggled_cb, self); setup_password_widget (self, - "password_entry", - s_vpn, - NM_IODINE_KEY_PASSWORD); + "password_entry", + s_vpn, + NM_IODINE_KEY_PASSWORD); init_one_pw_combo (self, s_vpn, @@ -493,19 +481,19 @@ init_plugin_ui (IodinePluginUiWidget *self, } static GObject * -get_widget (NMVpnPluginUiWidgetInterface *iface) +get_widget (NMVpnEditor *iface) { - IodinePluginUiWidget *self = IODINE_PLUGIN_UI_WIDGET (iface); - IodinePluginUiWidgetPrivate *priv = IODINE_PLUGIN_UI_WIDGET_GET_PRIVATE (self); + IodineEditor *self = IODINE_EDITOR (iface); + IodineEditorPrivate *priv = IODINE_EDITOR_GET_PRIVATE (self); return G_OBJECT (priv->widget); } static void -save_password_and_flags (NMSettingVPN *s_vpn, +save_password_and_flags (NMSettingVpn *s_vpn, GtkBuilder *builder, const char *entry_name, - const char *combo_name, + const char *combo_name, const char *secret_key) { NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE; @@ -540,14 +528,13 @@ save_password_and_flags (NMSettingVPN *s_vpn, } static gboolean -update_connection (NMVpnPluginUiWidgetInterface *iface, +update_connection (NMVpnEditor *iface, NMConnection *connection, GError **error) { - IodinePluginUiWidget *self = IODINE_PLUGIN_UI_WIDGET (iface); - IodinePluginUiWidgetPrivate *priv = \ - IODINE_PLUGIN_UI_WIDGET_GET_PRIVATE (self); - NMSettingVPN *s_vpn; + IodineEditor *self = IODINE_EDITOR (iface); + IodineEditorPrivate *priv = IODINE_EDITOR_GET_PRIVATE (self); + NMSettingVpn *s_vpn; GtkWidget *widget; char *str; @@ -556,61 +543,57 @@ update_connection (NMVpnPluginUiWidgetInterface *iface, s_vpn = NM_SETTING_VPN (nm_setting_vpn_new ()); g_object_set (s_vpn, NM_SETTING_VPN_SERVICE_TYPE, - NM_DBUS_SERVICE_IODINE, - NULL); + NM_DBUS_SERVICE_IODINE, + NULL); - widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, - "topdomain_entry")); + widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "topdomain_entry")); g_assert(widget); str = (char *) gtk_entry_get_text (GTK_ENTRY (widget)); if (str && strlen (str)) nm_setting_vpn_add_data_item (s_vpn, NM_IODINE_KEY_TOPDOMAIN, str); - widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, - "nameserver_entry")); + widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "nameserver_entry")); g_assert(widget); str = (char *) gtk_entry_get_text (GTK_ENTRY (widget)); if (str && strlen (str)) nm_setting_vpn_add_data_item (s_vpn, NM_IODINE_KEY_NAMESERVER, str); - widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, - "fragsize_entry")); + widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "fragsize_entry")); g_assert(widget); str = (char *) gtk_entry_get_text (GTK_ENTRY (widget)); if (str && strlen (str)) nm_setting_vpn_add_data_item (s_vpn, NM_IODINE_KEY_FRAGSIZE, str); - /* User password and flags */ + /* User password and flags */ save_password_and_flags (s_vpn, - priv->builder, - "password_entry", - "pass_type_combo", - NM_IODINE_KEY_PASSWORD); + priv->builder, + "password_entry", + "pass_type_combo", + NM_IODINE_KEY_PASSWORD); nm_connection_add_setting (connection, NM_SETTING (s_vpn)); return TRUE; } -static NMVpnPluginUiWidgetInterface * -nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) +static NMVpnEditor * +nm_vpn_editor_interface_new (NMConnection *connection, GError **error) { - NMVpnPluginUiWidgetInterface *object; - IodinePluginUiWidgetPrivate *priv; + NMVpnEditor *object; + IodineEditorPrivate *priv; char *ui_file; if (error) g_return_val_if_fail (*error == NULL, NULL); - object = NM_VPN_PLUGIN_UI_WIDGET_INTERFACE \ - (g_object_new (IODINE_TYPE_PLUGIN_UI_WIDGET, NULL)); + object = g_object_new (IODINE_TYPE_EDITOR, NULL); if (!object) { - g_set_error (error, IODINE_PLUGIN_UI_ERROR, 0, - "could not create iodine object"); + g_set_error (error, IODINE_EDITOR_PLUGIN_ERROR, 0, + "could not create iodine object"); return NULL; } - priv = IODINE_PLUGIN_UI_WIDGET_GET_PRIVATE (object); + priv = IODINE_EDITOR_GET_PRIVATE (object); ui_file = g_strdup_printf ("%s/%s", UIDIR, "nm-iodine-dialog.ui"); priv->builder = gtk_builder_new (); @@ -619,7 +602,7 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) g_warning ("Couldn't load builder file: %s", error && *error ? (*error)->message : "(unknown)"); g_clear_error (error); - g_set_error (error, IODINE_PLUGIN_UI_ERROR, 0, + g_set_error (error, IODINE_EDITOR_PLUGIN_ERROR, 0, "could not load required resources at %s", ui_file); g_free (ui_file); g_object_unref (object); @@ -627,17 +610,16 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) } g_free (ui_file); - priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, - "iodine-vbox")); + priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "iodine-vbox")); if (!priv->widget) { - g_set_error (error, IODINE_PLUGIN_UI_ERROR, 0, - "could not load UI widget"); + g_set_error (error, IODINE_EDITOR_PLUGIN_ERROR, 0, + "could not load UI widget"); g_object_unref (object); return NULL; } g_object_ref_sink (priv->widget); - if (!init_plugin_ui (IODINE_PLUGIN_UI_WIDGET (object), connection, error)) { + if (!init_editor_plugin (IODINE_EDITOR (object), connection, error)) { g_object_unref (object); return NULL; } @@ -648,9 +630,9 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) static void dispose (GObject *object) { - IodinePluginUiWidget *plugin = IODINE_PLUGIN_UI_WIDGET (object); - IodinePluginUiWidgetPrivate *priv = \ - IODINE_PLUGIN_UI_WIDGET_GET_PRIVATE (plugin); + IodineEditor *plugin = IODINE_EDITOR (object); + IodineEditorPrivate *priv = \ + IODINE_EDITOR_GET_PRIVATE (plugin); if (priv->group) g_object_unref (priv->group); @@ -661,26 +643,26 @@ dispose (GObject *object) if (priv->builder) g_object_unref (priv->builder); - G_OBJECT_CLASS (iodine_plugin_ui_widget_parent_class)->dispose (object); + G_OBJECT_CLASS (iodine_editor_parent_class)->dispose (object); } static void -iodine_plugin_ui_widget_class_init (IodinePluginUiWidgetClass *req_class) +iodine_editor_class_init (IodineEditorClass *req_class) { GObjectClass *object_class = G_OBJECT_CLASS (req_class); - g_type_class_add_private (req_class, sizeof (IodinePluginUiWidgetPrivate)); + g_type_class_add_private (req_class, sizeof (IodineEditorPrivate)); object_class->dispose = dispose; } static void -iodine_plugin_ui_widget_init (IodinePluginUiWidget *plugin) +iodine_editor_init (IodineEditor *plugin) { } static void -iodine_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class) +iodine_editor_interface_init (NMVpnEditorInterface *iface_class) { /* interface implementation */ iface_class->get_widget = get_widget; @@ -688,32 +670,32 @@ iodine_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_clas } static guint32 -get_capabilities (NMVpnPluginUiInterface *iface) +get_capabilities (NMVpnEditorPlugin *iface) { - return (NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT | - NM_VPN_PLUGIN_UI_CAPABILITY_EXPORT); + return (NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT | + NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT); } -static NMVpnPluginUiWidgetInterface * -ui_factory (NMVpnPluginUiInterface *iface, - NMConnection *connection, - GError **error) +static NMVpnEditor * +get_editor (NMVpnEditorPlugin *iface, + NMConnection *connection, + GError **error) { - return nm_vpn_plugin_ui_widget_interface_new (connection, error); + return nm_vpn_editor_interface_new (connection, error); } static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) + GValue *value, GParamSpec *pspec) { switch (prop_id) { - case NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME: + case PROP_NAME: g_value_set_string (value, IODINE_PLUGIN_NAME); break; - case NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC: + case PROP_DESC: g_value_set_string (value, IODINE_PLUGIN_DESC); break; - case NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE: + case PROP_SERVICE: g_value_set_string (value, IODINE_PLUGIN_SERVICE); break; default: @@ -723,46 +705,45 @@ get_property (GObject *object, guint prop_id, } static void -iodine_plugin_ui_class_init (IodinePluginUiClass *req_class) +iodine_editor_plugin_class_init (IodineEditorPluginClass *req_class) { GObjectClass *object_class = G_OBJECT_CLASS (req_class); 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); + PROP_NAME, + NM_VPN_EDITOR_PLUGIN_NAME); g_object_class_override_property (object_class, - NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC, - NM_VPN_PLUGIN_UI_INTERFACE_DESC); + PROP_DESC, + NM_VPN_EDITOR_PLUGIN_DESCRIPTION); g_object_class_override_property (object_class, - NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE, - NM_VPN_PLUGIN_UI_INTERFACE_SERVICE); + PROP_SERVICE, + NM_VPN_EDITOR_PLUGIN_SERVICE); } static void -iodine_plugin_ui_init (IodinePluginUi *plugin) +iodine_editor_plugin_init (IodineEditorPlugin *plugin) { } static void -iodine_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class) +iodine_editor_plugin_interface_init (NMVpnEditorPluginInterface *iface_class) { /* interface implementation */ - iface_class->ui_factory = ui_factory; + iface_class->get_editor = get_editor; iface_class->get_capabilities = get_capabilities; iface_class->import_from_file = import; iface_class->export_to_file = export; } -G_MODULE_EXPORT NMVpnPluginUiInterface * -nm_vpn_plugin_ui_factory (GError **error) +G_MODULE_EXPORT NMVpnEditorPlugin * +nm_vpn_editor_plugin_factory (GError **error) { if (error) g_return_val_if_fail (*error == NULL, NULL); - return NM_VPN_PLUGIN_UI_INTERFACE (g_object_new (IODINE_TYPE_PLUGIN_UI, - NULL)); + return g_object_new (IODINE_TYPE_EDITOR_PLUGIN, NULL); } diff --git a/properties/nm-iodine.h b/properties/nm-iodine.h index 1769fff..4eeb892 100644 --- a/properties/nm-iodine.h +++ b/properties/nm-iodine.h @@ -24,60 +24,46 @@ #include <glib-object.h> -typedef enum -{ - IODINE_PLUGIN_UI_ERROR_UNKNOWN = 0, - IODINE_PLUGIN_UI_ERROR_INVALID_PROPERTY, - IODINE_PLUGIN_UI_ERROR_MISSING_PROPERTY -} IodinePluginUiError; +#define IODINE_TYPE_EDITOR_PLUGIN (iodine_editor_plugin_get_type ()) +#define IODINE_EDITOR_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IODINE_TYPE_EDITOR_PLUGIN, IodineEditorPlugin)) +#define IODINE_EDITOR_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IODINE_TYPE_EDITOR_PLUGIN, IodineEditorPluginClass)) +#define IODINE_IS_EDITOR_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IODINE_TYPE_EDITOR_PLUGIN)) +#define IODINE_IS_EDITOR_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IODINE_TYPE_EDITOR_PLUGIN)) +#define IODINE_EDITOR_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IODINE_TYPE_EDITOR_PLUGIN, IodineEditorPluginClass)) +typedef struct _IodineEditorPlugin IodineEditorPlugin; +typedef struct _IodineEditorPluginClass IodineEditorPluginClass; -GQuark iodine_plugin_ui_error_quark (void); -#define IODINE_PLUGIN_UI_ERROR iodine_plugin_ui_error_quark () - -#define IODINE_TYPE_PLUGIN_UI_ERROR (iodine_plugin_ui_error_get_type ()) -GType iodine_plugin_ui_error_get_type (void); - -#define IODINE_TYPE_PLUGIN_UI (iodine_plugin_ui_get_type ()) -#define IODINE_PLUGIN_UI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IODINE_TYPE_PLUGIN_UI, IodinePluginUi)) -#define IODINE_PLUGIN_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IODINE_TYPE_PLUGIN_UI, IodinePluginUiClass)) -#define IODINE_IS_PLUGIN_UI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IODINE_TYPE_PLUGIN_UI)) -#define IODINE_IS_PLUGIN_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), IODINE_TYPE_PLUGIN_UI)) -#define IODINE_PLUGIN_UI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IODINE_TYPE_PLUGIN_UI, IodinePluginUiClass)) - -typedef struct _IodinePluginUi IodinePluginUi; -typedef struct _IodinePluginUiClass IodinePluginUiClass; - -struct _IodinePluginUi { +struct _IodineEditorPlugin { GObject parent; }; -struct _IodinePluginUiClass { +struct _IodineEditorPluginClass { GObjectClass parent; }; -GType iodine_plugin_ui_get_type (void); +GType iodine_editor_plugin_get_type (void); -#define IODINE_TYPE_PLUGIN_UI_WIDGET (iodine_plugin_ui_widget_get_type ()) -#define IODINE_PLUGIN_UI_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IODINE_TYPE_PLUGIN_UI_WIDGET, IodinePluginUiWidget)) -#define IODINE_PLUGIN_UI_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IODINE_TYPE_PLUGIN_UI_WIDGET, IodinePluginUiWidgetClass)) -#define IODINE_IS_PLUGIN_UI_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IODINE_TYPE_PLUGIN_UI_WIDGET)) -#define IODINE_IS_PLUGIN_UI_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), IODINE_TYPE_PLUGIN_UI_WIDGET)) -#define IODINE_PLUGIN_UI_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IODINE_TYPE_PLUGIN_UI_WIDGET, IodinePluginUiWidgetClass)) +#define IODINE_TYPE_EDITOR (iodine_editor_get_type ()) +#define IODINE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IODINE_TYPE_EDITOR, IodineEditor)) +#define IODINE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IODINE_TYPE_EDITOR, IodineEditorClass)) +#define IODINE_IS_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IODINE_TYPE_EDITOR)) +#define IODINE_IS_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IODINE_TYPE_EDITOR)) +#define IODINE_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IODINE_TYPE_EDITOR, IodineEditorClass)) -typedef struct _IodinePluginUiWidget IodinePluginUiWidget; -typedef struct _IodinePluginUiWidgetClass IodinePluginUiWidgetClass; +typedef struct _IodineEditor IodineEditor; +typedef struct _IodineEditorClass IodineEditorClass; -struct _IodinePluginUiWidget { +struct _IodineEditor { GObject parent; }; -struct _IodinePluginUiWidgetClass { +struct _IodineEditorClass { GObjectClass parent; }; -GType iodine_plugin_ui_widget_get_type (void); +GType iodine_editor_get_type (void); #endif /* _NM_IODINE_H_ */ diff --git a/src/Makefile.am b/src/Makefile.am index c7f3a1e..d412962 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,9 +1,5 @@ -INCLUDES = -I${top_srcdir} - AM_CPPFLAGS = \ - $(DBUS_CFLAGS) \ - $(GTHREAD_CFLAGS) \ - $(NM_CFLAGS) \ + $(LIBNM_CFLAGS) \ -DG_DISABLE_DEPRECATED \ -DBINDIR=\"$(bindir)\" \ -DPREFIX=\""$(prefix)"\" \ @@ -19,12 +15,10 @@ libexec_PROGRAMS = \ nm_iodine_service_SOURCES = \ nm-iodine-service.c \ - nm-iodine-service.h - + nm-iodine-service.h \ + nm-iodine-service-defines.h nm_iodine_service_LDADD = \ - $(DBUS_LIBS) \ - $(GTHREAD_LIBS) \ - $(NM_LIBS) + $(LIBNM_LIBS) CLEANFILES = *~ diff --git a/src/nm-iodine-service-defines.h b/src/nm-iodine-service-defines.h new file mode 100644 index 0000000..2663cbf --- /dev/null +++ b/src/nm-iodine-service-defines.h @@ -0,0 +1,33 @@ +/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ +/* NetworkManager -- Network link manager + * + * 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. + * + * 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. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright © 2012 Guido Günther <agx@sigxcpu.org> + */ + +#ifndef NM_IODINE_SERVICE_DEFINES_H +#define NM_IODINE_SERVICE_DEFINES_H + +#define NM_DBUS_SERVICE_IODINE "org.freedesktop.NetworkManager.iodine" +#define NM_DBUS_INTERFACE_IODINE "org.freedesktop.NetworkManager.iodine" +#define NM_DBUS_PATH_IODINE "/org/freedesktop/NetworkManager/iodine" + +#define NM_IODINE_KEY_TOPDOMAIN "topdomain" +#define NM_IODINE_KEY_NAMESERVER "nameserver" +#define NM_IODINE_KEY_FRAGSIZE "fragsize" +#define NM_IODINE_KEY_PASSWORD "password" + +#endif /* NM_IODINE_SERVICE_DEFINES_H */ diff --git a/src/nm-iodine-service.c b/src/nm-iodine-service.c index c99c384..89023d4 100644 --- a/src/nm-iodine-service.c +++ b/src/nm-iodine-service.c @@ -40,23 +40,25 @@ #include <pwd.h> #include <grp.h> #include <glib/gi18n.h> +#include <arpa/inet.h> -#include <nm-setting-vpn.h> +#include <NetworkManager.h> +#include <nm-vpn-service-plugin.h> #include "nm-iodine-service.h" #include "nm-utils.h" #define NM_IODINE_USER "nm-iodine" #define NM_IODINE_RUNDIR LOCALSTATEDIR "/run/" NM_IODINE_USER -G_DEFINE_TYPE (NMIODINEPlugin, nm_iodine_plugin, NM_TYPE_VPN_PLUGIN) +G_DEFINE_TYPE (NMIodinePlugin, nm_iodine_plugin, NM_TYPE_VPN_SERVICE_PLUGIN) typedef struct { GPid pid; - NMVPNPluginFailure failure; - GHashTable *ip4config; -} NMIODINEPluginPrivate; + NMVpnPluginFailure failure; + GVariantBuilder ip4config; +} NMIodinePluginPrivate; -#define NM_IODINE_PLUGIN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IODINE_PLUGIN, NMIODINEPluginPrivate)) +#define NM_IODINE_PLUGIN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IODINE_PLUGIN, NMIodinePluginPrivate)) static const char *iodine_binary_paths[] = { @@ -129,7 +131,7 @@ validate_one_property (const char *key, const char *value, gpointer user_data) NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, _("invalid integer property '%s' or out of range " - "[%d -> %d]"), + "[%d -> %d]"), key, prop.int_min, prop.int_max); break; case G_TYPE_BOOLEAN: @@ -153,7 +155,7 @@ validate_one_property (const char *key, const char *value, gpointer user_data) } /* Did not find the property from valid_properties or the type did not - match */ + match */ if (!info->table[i].name && strncmp(key, "form:", 5)) { g_warning ("property '%s' unknown", key); if (0) @@ -166,7 +168,7 @@ validate_one_property (const char *key, const char *value, gpointer user_data) } static gboolean -nm_iodine_properties_validate (NMSettingVPN *s_vpn, GError **error) +nm_iodine_properties_validate (NMSettingVpn *s_vpn, GError **error) { ValidateInfo info = { &valid_properties[0], error, FALSE }; @@ -185,7 +187,7 @@ nm_iodine_properties_validate (NMSettingVPN *s_vpn, GError **error) static gboolean -nm_iodine_secrets_validate (NMSettingVPN *s_vpn, GError **error) +nm_iodine_secrets_validate (NMSettingVpn *s_vpn, GError **error) { ValidateInfo info = { &valid_secrets[0], error, FALSE }; @@ -202,52 +204,32 @@ nm_iodine_secrets_validate (NMSettingVPN *s_vpn, GError **error) return *error ? FALSE : TRUE; } -static GValue * -str_to_gvalue (const char *str, gboolean try_convert) +static GVariant * +str_to_gvariant (const char *str, gboolean try_convert) { - GValue *val; - /* Empty */ if (!str || strlen (str) < 1) return NULL; if (!g_utf8_validate (str, -1, NULL)) { if (try_convert && !(str = g_convert (str, - -1, - "ISO-8859-1", - "UTF-8", - NULL, - NULL, - NULL))) + -1, + "ISO-8859-1", + "UTF-8", + NULL, + NULL, + NULL))) str = g_convert (str, -1, "C", "UTF-8", NULL, NULL, NULL); if (!str) /* Invalid */ return NULL; } - val = g_slice_new0 (GValue); - g_value_init (val, G_TYPE_STRING); - g_value_set_string (val, str); - return val; + return g_variant_new_string (str); } -static GValue * -uint_to_gvalue (guint32 num) -{ - GValue *val; - - if (num == 0) - return NULL; - - val = g_slice_new0 (GValue); - g_value_init (val, G_TYPE_UINT); - g_value_set_uint (val, num); - - return val; -} - -static GValue * -addr_to_gvalue (const char *str) +static GVariant * +addr4_to_gvariant (const char *str) { struct in_addr temp_addr; @@ -258,26 +240,16 @@ addr_to_gvalue (const char *str) if (inet_pton (AF_INET, str, &temp_addr) <= 0) return NULL; - return uint_to_gvalue (temp_addr.s_addr); -} - -static void -value_destroy (gpointer data) -{ - GValue *val = (GValue *) data; - - g_value_unset (val); - g_slice_free (GValue, val); + return g_variant_new_uint32 (temp_addr.s_addr); } static gint -iodine_parse_stderr_line (NMVPNPlugin *plugin, - const char* line, - GHashTable *ip4config) +iodine_parse_stderr_line (NMVpnServicePlugin *plugin, + const char* line) { - NMIODINEPluginPrivate *priv = NM_IODINE_PLUGIN_GET_PRIVATE (plugin); + NMIodinePluginPrivate *priv = NM_IODINE_PLUGIN_GET_PRIVATE (plugin); gchar **split = NULL; - GValue *val; + GVariant *val; gint len; gint ret = 1; @@ -295,60 +267,60 @@ iodine_parse_stderr_line (NMVPNPlugin *plugin, if (g_str_has_prefix(line, "Server tunnel IP is ")) { g_message("PTP address: %s", split[len-1]); - val = addr_to_gvalue (split[len-1]); + val = addr4_to_gvariant (split[len-1]); if (val) - g_hash_table_insert (ip4config, - NM_VPN_PLUGIN_IP4_CONFIG_PTP, - val); - val = addr_to_gvalue (split[len-1]); + g_variant_builder_add (&priv->ip4config, "{sv}", + NM_VPN_PLUGIN_IP4_CONFIG_PTP, + val); + val = addr4_to_gvariant (split[len-1]); if (val) - g_hash_table_insert (ip4config, - NM_VPN_PLUGIN_IP4_CONFIG_INT_GATEWAY, - val); + g_variant_builder_add (&priv->ip4config, "{sv}", + NM_VPN_PLUGIN_IP4_CONFIG_INT_GATEWAY, + val); } else if (g_str_has_prefix(line, "Sending DNS queries for ")) { g_message("External gw: %s", split[len-1]); - val = addr_to_gvalue (split[len-1]); + val = addr4_to_gvariant (split[len-1]); if (val) - g_hash_table_insert (ip4config, - NM_VPN_PLUGIN_IP4_CONFIG_EXT_GATEWAY, - val); + g_variant_builder_add (&priv->ip4config, "{sv}", + NM_VPN_PLUGIN_IP4_CONFIG_EXT_GATEWAY, + val); } else if (g_str_has_prefix(line, "Sending raw traffic directly to ")) { /* If the DNS server is directly reachable we need to set it as external gateway overwriting the above valus */ g_message("Overwrite ext. gw. address: %s", split[len-1]); - val = addr_to_gvalue (split[len-1]); + val = addr4_to_gvariant (split[len-1]); if (val) - g_hash_table_insert (ip4config, - NM_VPN_PLUGIN_IP4_CONFIG_EXT_GATEWAY, - val); + g_variant_builder_add (&priv->ip4config, "{sv}", + NM_VPN_PLUGIN_IP4_CONFIG_EXT_GATEWAY, + val); } else if (g_str_has_prefix(line, "Setting IP of dns")) { g_message("Address: %s", split[len-1]); - val = addr_to_gvalue (split[len-1]); + val = addr4_to_gvariant (split[len-1]); if (val) - g_hash_table_insert (ip4config, - NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS, - val); + g_variant_builder_add (&priv->ip4config, "{sv}", + NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS, + val); } else if (g_str_has_prefix(line, "Setting MTU of ")) { g_message("MTU: %s", split[len-1]); - val = addr_to_gvalue (split[len-1]); + val = addr4_to_gvariant (split[len-1]); if (val) - g_hash_table_insert (ip4config, - NM_VPN_PLUGIN_IP4_CONFIG_MTU, - val); + g_variant_builder_add (&priv->ip4config, "{sv}", + NM_VPN_PLUGIN_IP4_CONFIG_MTU, + val); } else if (g_str_has_prefix(line, "Opened dns")) { g_message("Interface: %s", split[len-1]); - val = str_to_gvalue (split[len-1], FALSE); + val = str_to_gvariant (split[len-1], FALSE); if (val) - g_hash_table_insert (ip4config, - NM_VPN_PLUGIN_IP4_CONFIG_TUNDEV, - val); + g_variant_builder_add (&priv->ip4config, "{sv}", + NM_VPN_PLUGIN_IP4_CONFIG_TUNDEV, + val); } else if (g_str_has_prefix(line, - "Connection setup complete, " - "transmitting data.")) { - val = uint_to_gvalue(27); - g_hash_table_insert (ip4config, - NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, - val); + "Connection setup complete, " + "transmitting data.")) { + val = g_variant_new_uint32 (27); + g_variant_builder_add (&priv->ip4config, "{sv}", + NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, + val); ret = 0; /* success */ } else g_message("%s", line); @@ -366,7 +338,7 @@ iodine_stderr_cb (GIOChannel *source, GIOCondition condition, gpointer plugin) GError *err = NULL; gchar *line; gint ret, l; - NMIODINEPluginPrivate *priv = NM_IODINE_PLUGIN_GET_PRIVATE (plugin); + NMIodinePluginPrivate *priv = NM_IODINE_PLUGIN_GET_PRIVATE (plugin); status = g_io_channel_read_line (source, &line, NULL, NULL, &err); if (status != G_IO_STATUS_NORMAL) { @@ -378,13 +350,11 @@ iodine_stderr_cb (GIOChannel *source, GIOCondition condition, gpointer plugin) if (l) line[l-1] = '\0'; - ret = iodine_parse_stderr_line(plugin, line, priv->ip4config); + ret = iodine_parse_stderr_line(plugin, line); if (!ret) { g_message("Parsing done, sending IP4 config"); - nm_vpn_plugin_set_ip4_config(plugin, priv->ip4config); - - g_hash_table_destroy (priv->ip4config); - priv->ip4config = NULL; + nm_vpn_service_plugin_set_ip4_config(plugin, + g_variant_builder_end (&priv->ip4config)); } g_free (line); return TRUE; @@ -394,8 +364,8 @@ iodine_stderr_cb (GIOChannel *source, GIOCondition condition, gpointer plugin) static void iodine_watch_cb (GPid pid, gint status, gpointer user_data) { - NMIODINEPlugin *plugin = NM_IODINE_PLUGIN (user_data); - NMIODINEPluginPrivate *priv = NM_IODINE_PLUGIN_GET_PRIVATE (plugin); + NMIodinePlugin *plugin = NM_IODINE_PLUGIN (user_data); + NMIodinePluginPrivate *priv = NM_IODINE_PLUGIN_GET_PRIVATE (plugin); guint error = 0; if (WIFEXITED (status)) { @@ -416,15 +386,12 @@ iodine_watch_cb (GPid pid, gint status, gpointer user_data) priv->pid = 0; if (priv->failure >= 0) { - nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), - priv->failure); + nm_vpn_service_plugin_failure (NM_VPN_SERVICE_PLUGIN (plugin), priv->failure); } else if (error) { - nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), - NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED); + nm_vpn_service_plugin_failure (NM_VPN_SERVICE_PLUGIN (plugin), NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED); + } else { + nm_vpn_service_plugin_disconnect (NM_VPN_SERVICE_PLUGIN (plugin), NULL); } - - nm_vpn_plugin_set_state (NM_VPN_PLUGIN (plugin), - NM_VPN_SERVICE_STATE_STOPPED); } static gboolean @@ -435,7 +402,7 @@ has_user(const char* user) static void -send_password(gint fd, NMSettingVPN *s_vpn) +send_password(gint fd, NMSettingVpn *s_vpn) { const char *passwd; ssize_t ret; @@ -455,16 +422,16 @@ send_password(gint fd, NMSettingVPN *s_vpn) static gint -nm_iodine_start_iodine_binary(NMIODINEPlugin *plugin, - NMSettingVPN *s_vpn, - GError **error) +nm_iodine_start_iodine_binary (NMIodinePlugin *plugin, + NMSettingVpn *s_vpn, + GError **error) { - GPid pid; + GPid pid; const char **iodine_binary = NULL; GPtrArray *iodine_argv; GSource *iodine_watch; GIOChannel *stderr_channel; - gint stdin_fd, stderr_fd; + gint stdin_fd, stderr_fd; const char *props_topdomain, *props_fragsize, *props_nameserver; /* Find iodine */ @@ -484,12 +451,9 @@ nm_iodine_start_iodine_binary(NMIODINEPlugin *plugin, return -1; } - props_fragsize = nm_setting_vpn_get_data_item (s_vpn, - NM_IODINE_KEY_FRAGSIZE); - props_nameserver = nm_setting_vpn_get_data_item (s_vpn, - NM_IODINE_KEY_NAMESERVER); - props_topdomain = nm_setting_vpn_get_data_item (s_vpn, - NM_IODINE_KEY_TOPDOMAIN); + props_fragsize = nm_setting_vpn_get_data_item (s_vpn, NM_IODINE_KEY_FRAGSIZE); + props_nameserver = nm_setting_vpn_get_data_item (s_vpn, NM_IODINE_KEY_NAMESERVER); + props_topdomain = nm_setting_vpn_get_data_item (s_vpn, NM_IODINE_KEY_TOPDOMAIN); iodine_argv = g_ptr_array_new (); g_ptr_array_add (iodine_argv, (gpointer) (*iodine_binary)); /* Run in foreground */ @@ -521,9 +485,9 @@ nm_iodine_start_iodine_binary(NMIODINEPlugin *plugin, g_ptr_array_add (iodine_argv, NULL); if (!g_spawn_async_with_pipes (NULL, (char **) iodine_argv->pdata, NULL, - G_SPAWN_DO_NOT_REAP_CHILD, - NULL, NULL, - &pid, &stdin_fd, NULL, &stderr_fd, error)) { + G_SPAWN_DO_NOT_REAP_CHILD, + NULL, NULL, + &pid, &stdin_fd, NULL, &stderr_fd, error)) { g_ptr_array_free (iodine_argv, TRUE); g_warning ("iodine failed to start. error: '%s'", (*error)->message); return -1; @@ -537,16 +501,16 @@ nm_iodine_start_iodine_binary(NMIODINEPlugin *plugin, stderr_channel = g_io_channel_unix_new (stderr_fd); g_io_add_watch(stderr_channel, - G_IO_IN, - iodine_stderr_cb, - plugin); + G_IO_IN, + iodine_stderr_cb, + plugin); NM_IODINE_PLUGIN_GET_PRIVATE (plugin)->pid = pid; iodine_watch = g_child_watch_source_new (pid); g_source_set_callback (iodine_watch, - (GSourceFunc) iodine_watch_cb, - plugin, - NULL); + (GSourceFunc) iodine_watch_cb, + plugin, + NULL); g_source_attach (iodine_watch, NULL); g_source_unref (iodine_watch); @@ -554,15 +518,14 @@ nm_iodine_start_iodine_binary(NMIODINEPlugin *plugin, } static gboolean -real_connect (NMVPNPlugin *plugin, - NMConnection *connection, - GError **error) +real_connect (NMVpnServicePlugin *plugin, + NMConnection *connection, + GError **error) { - NMSettingVPN *s_vpn; + NMSettingVpn *s_vpn; gint ret = -1; - s_vpn = NM_SETTING_VPN (nm_connection_get_setting (connection, - NM_TYPE_SETTING_VPN)); + s_vpn = nm_connection_get_setting_vpn (connection); g_assert (s_vpn); if (!nm_iodine_properties_validate (s_vpn, error)) goto out; @@ -570,8 +533,7 @@ real_connect (NMVPNPlugin *plugin, if (!nm_iodine_secrets_validate (s_vpn, error)) goto out; - ret = nm_iodine_start_iodine_binary (NM_IODINE_PLUGIN (plugin), - s_vpn, error); + ret = nm_iodine_start_iodine_binary (NM_IODINE_PLUGIN (plugin), s_vpn, error); if (!ret) return TRUE; @@ -580,26 +542,24 @@ real_connect (NMVPNPlugin *plugin, } static gboolean -real_need_secrets (NMVPNPlugin *plugin, - - NMConnection *connection, - char **setting_name, - GError **error) +real_need_secrets (NMVpnServicePlugin *plugin, + NMConnection *connection, + const char **setting_name, + GError **error) { - NMSettingVPN *s_vpn; + NMSettingVpn *s_vpn; - g_return_val_if_fail (NM_IS_VPN_PLUGIN (plugin), FALSE); + g_return_val_if_fail (NM_IS_VPN_SERVICE_PLUGIN (plugin), FALSE); g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE); - s_vpn = NM_SETTING_VPN (nm_connection_get_setting (connection, - NM_TYPE_SETTING_VPN)); + s_vpn = nm_connection_get_setting_vpn (connection); if (!s_vpn) { - g_set_error (error, + g_set_error (error, NM_VPN_PLUGIN_ERROR, - NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID, + NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION, "%s", - "Could not process the request because the VPN" - "connection settings were invalid."); + "Could not process the request because the VPN " + "connection settings were invalid."); return FALSE; } @@ -623,10 +583,9 @@ ensure_killed (gpointer data) } static gboolean -real_disconnect (NMVPNPlugin *plugin, - GError **err) +real_disconnect (NMVpnServicePlugin *plugin, GError **err) { - NMIODINEPluginPrivate *priv = NM_IODINE_PLUGIN_GET_PRIVATE (plugin); + NMIodinePluginPrivate *priv = NM_IODINE_PLUGIN_GET_PRIVATE (plugin); if (priv->pid) { if (kill (priv->pid, SIGTERM) == 0) @@ -642,24 +601,21 @@ real_disconnect (NMVPNPlugin *plugin, } static void -nm_iodine_plugin_init (NMIODINEPlugin *plugin) +nm_iodine_plugin_init (NMIodinePlugin *plugin) { - NMIODINEPluginPrivate *priv = NM_IODINE_PLUGIN_GET_PRIVATE (plugin); + NMIodinePluginPrivate *priv = NM_IODINE_PLUGIN_GET_PRIVATE (plugin); - priv->ip4config = g_hash_table_new_full (g_str_hash, - g_str_equal, - NULL, - value_destroy); + g_variant_builder_init (&priv->ip4config, G_VARIANT_TYPE_VARDICT); priv->failure = -1; } static void -nm_iodine_plugin_class_init (NMIODINEPluginClass *iodine_class) +nm_iodine_plugin_class_init (NMIodinePluginClass *iodine_class) { GObjectClass *object_class = G_OBJECT_CLASS (iodine_class); - NMVPNPluginClass *parent_class = NM_VPN_PLUGIN_CLASS (iodine_class); + NMVpnServicePluginClass *parent_class = NM_VPN_SERVICE_PLUGIN_CLASS (iodine_class); - g_type_class_add_private (object_class, sizeof (NMIODINEPluginPrivate)); + g_type_class_add_private (object_class, sizeof (NMIodinePluginPrivate)); /* virtual methods */ parent_class->connect = real_connect; @@ -667,24 +623,34 @@ nm_iodine_plugin_class_init (NMIODINEPluginClass *iodine_class) parent_class->disconnect = real_disconnect; } -NMIODINEPlugin * +NMIodinePlugin * nm_iodine_plugin_new (void) { - return (NMIODINEPlugin *) g_object_new (NM_TYPE_IODINE_PLUGIN, - NM_VPN_PLUGIN_DBUS_SERVICE_NAME, - NM_DBUS_SERVICE_IODINE, - NULL); + NMIodinePlugin *plugin; + GError *error = NULL; + + plugin = (NMIodinePlugin *) g_initable_new (NM_TYPE_IODINE_PLUGIN, NULL, &error, + NM_VPN_SERVICE_PLUGIN_DBUS_SERVICE_NAME, + NM_DBUS_SERVICE_IODINE, + NULL); + + if (!plugin) { + g_warning ("Failed to initialize a plugin instance: %s", error->message); + g_error_free (error); + } + + return plugin; } static void -quit_mainloop (NMIODINEPlugin *plugin, gpointer user_data) +quit_mainloop (NMIodinePlugin *plugin, gpointer user_data) { g_main_loop_quit ((GMainLoop *) user_data); } int main (int argc, char *argv[]) { - NMIODINEPlugin *plugin; + NMIodinePlugin *plugin; GMainLoop *main_loop; #if !GLIB_CHECK_VERSION(2,36,0) @@ -698,8 +664,8 @@ int main (int argc, char *argv[]) main_loop = g_main_loop_new (NULL, FALSE); g_signal_connect (plugin, "quit", - G_CALLBACK (quit_mainloop), - main_loop); + G_CALLBACK (quit_mainloop), + main_loop); g_main_loop_run (main_loop); diff --git a/src/nm-iodine-service.h b/src/nm-iodine-service.h index 48e2e46..1102cc0 100644 --- a/src/nm-iodine-service.h +++ b/src/nm-iodine-service.h @@ -22,34 +22,28 @@ #define NM_IODINE_PLUGIN_H #include <glib.h> -#include <nm-vpn-plugin.h> +#include <NetworkManager.h> +#include <nm-vpn-service-plugin.h> + +#include "nm-iodine-service-defines.h" #define NM_TYPE_IODINE_PLUGIN (nm_iodine_plugin_get_type ()) -#define NM_IODINE_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IODINE_PLUGIN, NMIODINEPlugin)) -#define NM_IODINE_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IODINE_PLUGIN, NMIODINEPluginClass)) +#define NM_IODINE_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IODINE_PLUGIN, NMIodinePlugin)) +#define NM_IODINE_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IODINE_PLUGIN, NMIodinePluginClass)) #define NM_IS_IODINE_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IODINE_PLUGIN)) -#define NM_IS_IODINE_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_IODINE_PLUGIN)) -#define NM_IODINE_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IODINE_PLUGIN, NMIODINEPluginClass)) - -#define NM_DBUS_SERVICE_IODINE "org.freedesktop.NetworkManager.iodine" -#define NM_DBUS_INTERFACE_IODINE "org.freedesktop.NetworkManager.iodine" -#define NM_DBUS_PATH_IODINE "/org/freedesktop/NetworkManager/iodine" - -#define NM_IODINE_KEY_TOPDOMAIN "topdomain" -#define NM_IODINE_KEY_NAMESERVER "nameserver" -#define NM_IODINE_KEY_FRAGSIZE "fragsize" -#define NM_IODINE_KEY_PASSWORD "password" +#define NM_IS_IODINE_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IODINE_PLUGIN)) +#define NM_IODINE_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IODINE_PLUGIN, NMIodinePluginClass)) typedef struct { - NMVPNPlugin parent; -} NMIODINEPlugin; + NMVpnServicePlugin parent; +} NMIodinePlugin; typedef struct { - NMVPNPluginClass parent; -} NMIODINEPluginClass; + NMVpnServicePluginClass parent; +} NMIodinePluginClass; GType nm_iodine_plugin_get_type (void); -NMIODINEPlugin *nm_iodine_plugin_new (void); +NMIodinePlugin *nm_iodine_plugin_new (void); #endif /* NM_IODINE_PLUGIN_H */ |