From 03ccd23708f0714a5446c7541d31e1233c5d2e33 Mon Sep 17 00:00:00 2001 From: Max Moser Date: Sun, 11 Feb 2018 23:17:22 +0100 Subject: [PATCH] Move import-export to shared/ in order to be able to use it in the actual plugin --- Makefile.am | 9 +++++---- {properties => shared}/import-export.c | 14 +++----------- {properties => shared}/import-export.h | 2 ++ 3 files changed, 10 insertions(+), 15 deletions(-) rename {properties => shared}/import-export.c (98%) rename {properties => shared}/import-export.h (95%) diff --git a/Makefile.am b/Makefile.am index cd6e310..343a8b4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,7 +35,8 @@ ui_DATA = shared_sources = \ shared/nm-utils/nm-shared-utils.c \ - shared/utils.c + shared/utils.c \ + shared/import-export.c ############################################################################### @@ -102,9 +103,7 @@ EXTRA_DIST += \ plugin_sources = \ properties/nm-openvpn-editor-plugin.c \ - properties/nm-openvpn-editor-plugin.h \ - properties/import-export.c \ - properties/import-export.h + properties/nm-openvpn-editor-plugin.h editor_sources = \ properties/resources.c \ @@ -400,6 +399,8 @@ EXTRA_DIST += \ shared/nm-service-defines.h \ shared/utils.c \ shared/utils.h \ + shared/import-export.c \ + shared/import-export.h \ $(NULL) CLEANFILES += \ diff --git a/properties/import-export.c b/shared/import-export.c similarity index 98% rename from properties/import-export.c rename to shared/import-export.c index c67c259..4518a95 100644 --- a/properties/import-export.c +++ b/shared/import-export.c @@ -1183,8 +1183,8 @@ args_write_line_setting_value (GString *f, /*****************************************************************************/ -static GString * -do_export_create (NMConnection *connection, const char *path, GError **error) +GString * +create_config_string (NMConnection *connection, GError **error) { NMSettingConnection *s_con; NMSettingVpn *s_vpn; @@ -1203,14 +1203,6 @@ do_export_create (NMConnection *connection, const char *path, GError **error) GArray *ips; nm_auto(_auto_free_gstring_p) GString *f = NULL; - if (!path || !path[0]) { - g_set_error_literal (error, - NMV_EDITOR_PLUGIN_ERROR, - NMV_EDITOR_PLUGIN_ERROR_FILE_NOT_VPN, - _("missing path argument")); - return NULL; - } - s_con = nm_connection_get_setting_connection (connection); s_vpn = nm_connection_get_setting_vpn (connection); if (!s_con || !s_vpn) { @@ -1330,7 +1322,7 @@ do_export (const char *path, NMConnection *connection, GError **error) nm_auto(_auto_free_gstring_p) GString *f = NULL; gs_free_error GError *local = NULL; - f = do_export_create (connection, path, error); + f = create_config_string (connection, error); if (!f) return FALSE; diff --git a/properties/import-export.h b/shared/import-export.h similarity index 95% rename from properties/import-export.h rename to shared/import-export.h index 06b92a8..79b3d2c 100644 --- a/properties/import-export.h +++ b/shared/import-export.h @@ -33,4 +33,6 @@ NMConnection *do_import (const char *path, const char *contents, gsize contents_ gboolean do_export (const char *path, NMConnection *connection, GError **error); +GString *create_config_string (NMConnection *connection, GError **error); + #endif