[network-manager-libreswan/th/vpn-editor-split: 14/18] properties: fix detecting openswan in export_to_file()



commit eb2f5d48873941087cca816a9a853a2bc94a4eb3
Author: Thomas Haller <thaller redhat com>
Date:   Tue May 10 15:42:02 2016 +0200

    properties: fix detecting openswan in export_to_file()
    
    export_to_file() is a function of NMVpnEditorPlugin -- not NMVpnEditor
    (or LibreswanEditor). We cannot obtain the private data of the latter
    and must detect whether to use openswan somehow different.

 properties/nm-libreswan.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/properties/nm-libreswan.c b/properties/nm-libreswan.c
index 0dbfec9..9d867d0 100644
--- a/properties/nm-libreswan.c
+++ b/properties/nm-libreswan.c
@@ -76,7 +76,6 @@ typedef struct {
        GtkBuilder *builder;
        GtkWidget *widget;
        GtkSizeGroup *group;
-       gboolean openswan;
 } LibreswanEditorPrivate;
 
 
@@ -315,11 +314,6 @@ init_editor_plugin (LibreswanEditor *self,
                          (GCallback) show_toggled_cb,
                          self);
 
-       if (s_vpn) {
-               const char *type = nm_setting_vpn_get_service_type (s_vpn);
-               priv->openswan = (g_strcmp0 (type, NM_VPN_SERVICE_TYPE_OPENSWAN) == 0);
-       }
-
        return TRUE;
 }
 
@@ -584,7 +578,8 @@ export_to_file (NMVpnEditorPlugin *self,
                 NMConnection *connection,
                 GError **error)
 {
-       LibreswanEditorPrivate *priv = LIBRESWAN_EDITOR_GET_PRIVATE (self);
+       NMSettingVpn *s_vpn;
+       gboolean openswan = FALSE;
        int fd;
 
        fd = g_open (path, O_WRONLY | O_CREAT, 0777);
@@ -594,7 +589,11 @@ export_to_file (NMVpnEditorPlugin *self,
                return FALSE;
        }
 
-       nm_libreswan_config_write (fd, connection, NULL, priv->openswan);
+       s_vpn = nm_connection_get_setting_vpn (connection);
+       if (s_vpn)
+               openswan = nm_streq (nm_setting_vpn_get_service_type (s_vpn), NM_VPN_SERVICE_TYPE_OPENSWAN);
+
+       nm_libreswan_config_write (fd, connection, NULL, openswan);
 
        if (!g_close (fd, error))
                return FALSE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]