[NetworkManager-fortisslvpn/lr/export-import: 4/5] properties: add export capability
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [NetworkManager-fortisslvpn/lr/export-import: 4/5] properties: add export capability
- Date: Wed, 20 Mar 2019 23:02:48 +0000 (UTC)
commit 1347c727c551ce07a54b00814f036782e3c6f8a2
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Wed Mar 20 22:37:12 2019 +0100
properties: add export capability
Makefile.am | 8 +++++---
properties/nm-fortisslvpn-editor-plugin.c | 29 +++++++++++++++++++++++++++--
2 files changed, 32 insertions(+), 5 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index ee7fa9f..ecdb08a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -116,6 +116,10 @@ properties/resources.h: properties/gresource.xml
properties/resources.c: properties/gresource.xml $(shell $(GLIB_COMPILE_RESOURCES)
--sourcedir=$(srcdir)/properties --generate-dependencies $(srcdir)/properties/gresource.xml)
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ --sourcedir=$(srcdir)/properties
--generate-source --internal
+shared_sources = \
+ shared/nm-fortissl-properties.c \
+ shared/nm-fortissl-properties.h
+
plugin_sources = \
properties/nm-fortisslvpn-editor-plugin.c \
properties/nm-fortisslvpn-editor-plugin.h
@@ -124,9 +128,7 @@ editor_sources = \
properties/resources.c \
properties/resources.h \
properties/nm-fortisslvpn-editor.c \
- properties/nm-fortisslvpn-editor.h \
- shared/nm-fortissl-properties.c \
- shared/nm-fortissl-properties.h
+ properties/nm-fortisslvpn-editor.h
properties_cppflags = \
-DLOCALEDIR=\"$(datadir)/locale\" \
diff --git a/properties/nm-fortisslvpn-editor-plugin.c b/properties/nm-fortisslvpn-editor-plugin.c
index 0c5ff73..977d660 100644
--- a/properties/nm-fortisslvpn-editor-plugin.c
+++ b/properties/nm-fortisslvpn-editor-plugin.c
@@ -59,7 +59,7 @@ G_DEFINE_TYPE_EXTENDED (FortisslvpnEditorPlugin, fortisslvpn_editor_plugin, G_TY
static guint32
get_capabilities (NMVpnEditorPlugin *iface)
{
- return NM_VPN_EDITOR_PLUGIN_CAPABILITY_NONE;
+ return NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT;
}
#ifndef NM_VPN_OLD
@@ -98,6 +98,31 @@ get_editor (NMVpnEditorPlugin *iface, NMConnection *connection, GError **error)
}
}
+static gboolean
+export_to_file (NMVpnEditorPlugin *iface, const char *filename,
+ NMConnection *connection, GError **error)
+{
+ gs_unref_object GFile *file = NULL;
+ gs_unref_object GFileOutputStream *stream = NULL;
+ NMSettingVpn *s_vpn;
+
+ s_vpn = NM_SETTING_VPN (nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN));
+
+ file = g_file_new_for_path (filename);
+ stream = g_file_replace (file, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, NULL, error);
+ if (!stream) {
+ g_prefix_error (error, _("Can not open output file: "));
+ return FALSE;
+ }
+
+ if (!nm_fortisslvpn_write_config (G_OUTPUT_STREAM (stream), s_vpn, error)) {
+ g_prefix_error (error, _("Can not write output file: "));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
@@ -130,7 +155,7 @@ fortisslvpn_editor_plugin_interface_init (NMVpnEditorPluginInterface *iface_clas
iface_class->get_editor = get_editor;
iface_class->get_capabilities = get_capabilities;
iface_class->import_from_file = NULL;
- iface_class->export_to_file = NULL;
+ iface_class->export_to_file = export_to_file;
iface_class->get_suggested_filename = NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]