[network-manager-vpnc/th/vpn-editor-split-bgo766170: 4/19] shared: use "nm-default.h" header



commit 35698f494ed0643df9113e5c2d80b2ce2e578b88
Author: Thomas Haller <thaller redhat com>
Date:   Sun May 8 22:30:41 2016 +0200

    shared: use "nm-default.h" header

 auth-dialog/main.c                    |    9 +-----
 properties/Makefile.am                |    3 +-
 properties/nm-vpnc-helper.c           |    8 ++---
 properties/nm-vpnc.c                  |   56 ++++++---------------------------
 properties/nm-vpnc.h                  |    2 -
 properties/tests/Makefile.am          |    3 +-
 properties/tests/test-import-export.c |   15 +++-----
 shared/nm-default.h                   |    5 +++
 src/nm-vpnc-service-vpnc-helper.c     |    7 +---
 src/nm-vpnc-service.c                 |    9 ++---
 src/nm-vpnc-service.h                 |    6 ---
 src/test-vpnc-output.c                |    3 ++
 src/utils.c                           |    5 ++-
 src/utils.h                           |    2 -
 14 files changed, 41 insertions(+), 92 deletions(-)
---
diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index 530f362..2370208 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -20,23 +20,16 @@
  * (C) Copyright 2004 - 2011 Red Hat, Inc.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "nm-default.h"
 
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
-#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <libsecret/secret.h>
 
-#include <NetworkManager.h>
-#include <nm-vpn-service-plugin.h>
 #include <nma-vpn-password-dialog.h>
 
-#include "nm-vpnc-service-defines.h"
-
 #define KEYRING_UUID_TAG "connection-uuid"
 #define KEYRING_SN_TAG "setting-name"
 #define KEYRING_SK_TAG "setting-key"
diff --git a/properties/Makefile.am b/properties/Makefile.am
index 82ce18b..59db3d9 100644
--- a/properties/Makefile.am
+++ b/properties/Makefile.am
@@ -24,7 +24,8 @@ common_CFLAGS = \
        -I"$(top_srcdir)/shared/" \
        -DICONDIR=\""$(datadir)/pixmaps"\" \
        -DUIDIR=\""$(uidir)"\" \
-       -DLOCALEDIR=\"$(datadir)/locale\"
+       -DLOCALEDIR=\"$(datadir)/locale\" \
+       -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB
 
 libnm_vpn_plugin_vpnc_la_CFLAGS = \
        $(common_CFLAGS) \
diff --git a/properties/nm-vpnc-helper.c b/properties/nm-vpnc-helper.c
index 1ea66f8..33d7166 100644
--- a/properties/nm-vpnc-helper.c
+++ b/properties/nm-vpnc-helper.c
@@ -20,15 +20,13 @@
  *
  **************************************************************************/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "nm-default.h"
+
+#include "nm-vpnc-helper.h"
 
 #include <errno.h>
-#include <glib.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include "nm-vpnc-helper.h"
 
 gboolean
 key_file_get_boolean_helper (GKeyFile *keyfile,
diff --git a/properties/nm-vpnc.c b/properties/nm-vpnc.c
index 0f4f438..a328c84 100644
--- a/properties/nm-vpnc.c
+++ b/properties/nm-vpnc.c
@@ -24,9 +24,9 @@
  *
  **************************************************************************/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "nm-default.h"
+
+#include "nm-vpnc.h"
 
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -35,45 +35,9 @@
 #include <string.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-
-#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 
-#ifdef NM_VPNC_OLD
-#define NM_VPN_LIBNM_COMPAT
-
-#include <nm-setting-vpn.h>
-#include <nm-setting-connection.h>
-#include <nm-setting-ip4-config.h>
-#include <nm-ui-utils.h>
-#include <nm-vpn-plugin-ui-interface.h>
-
-#define nm_simple_connection_new() nm_connection_new ()
-
-#define NMSettingIPConfig NMSettingIP4Config
-#define NM_SETTING_IP_CONFIG(obj) NM_SETTING_IP4_CONFIG (obj)
-#define nm_setting_ip_config_get_num_routes nm_setting_ip4_config_get_num_routes
-#define nm_setting_ip_config_get_route nm_setting_ip4_config_get_route
-#define nm_setting_ip_config_add_route nm_setting_ip4_config_add_route
-#define NM_SETTING_IP_CONFIG_NEVER_DEFAULT NM_SETTING_IP4_CONFIG_NEVER_DEFAULT
-
-#define VPNC_PLUGIN_UI_ERROR                  NM_SETTING_VPN_ERROR
-#define VPNC_PLUGIN_UI_ERROR_FAILED           NM_SETTING_VPN_ERROR_UNKNOWN
-#define VPNC_PLUGIN_UI_ERROR_INVALID_PROPERTY NM_SETTING_VPN_ERROR_INVALID_PROPERTY
-
-#else /* !NM_VPNC_OLD */
-
-#include <NetworkManager.h>
-#include <nma-ui-utils.h>
-
-#define VPNC_PLUGIN_UI_ERROR                  NM_CONNECTION_ERROR
-#define VPNC_PLUGIN_UI_ERROR_FAILED           NM_CONNECTION_ERROR_FAILED
-#define VPNC_PLUGIN_UI_ERROR_INVALID_PROPERTY NM_CONNECTION_ERROR_INVALID_PROPERTY
-#endif
-
-#include "nm-vpnc-service-defines.h"
 #include "nm-vpnc-helper.h"
-#include "nm-vpnc.h"
 
 #define VPNC_PLUGIN_NAME    _("Cisco Compatible VPN (vpnc)")
 #define VPNC_PLUGIN_DESC    _("Compatible with various Cisco, Juniper, Netscreen, and Sonicwall IPsec-based 
VPN gateways.")
@@ -129,8 +93,8 @@ check_validity (VpncEditor *self, GError **error)
        str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
        if (!str || !strlen (str) || strstr (str, " ") || strstr (str, "\t")) {
                g_set_error (error,
-                            VPNC_PLUGIN_UI_ERROR,
-                            VPNC_PLUGIN_UI_ERROR_INVALID_PROPERTY,
+                            VPNC_EDITOR_PLUGIN_ERROR,
+                            VPNC_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY,
                             NM_VPNC_KEY_GATEWAY);
                return FALSE;
        }
@@ -139,8 +103,8 @@ check_validity (VpncEditor *self, GError **error)
        str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
        if (!str || !strlen (str)) {
                g_set_error (error,
-                            VPNC_PLUGIN_UI_ERROR,
-                            VPNC_PLUGIN_UI_ERROR_INVALID_PROPERTY,
+                            VPNC_EDITOR_PLUGIN_ERROR,
+                            VPNC_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY,
                             NM_VPNC_KEY_ID);
                return FALSE;
        }
@@ -1001,7 +965,7 @@ nm_vpnc_editor_new (NMConnection *connection, GError **error)
 
        object = g_object_new (VPNC_TYPE_EDITOR, NULL);
        if (!object) {
-               g_set_error (error, VPNC_PLUGIN_UI_ERROR, VPNC_PLUGIN_UI_ERROR_FAILED,
+               g_set_error (error, VPNC_EDITOR_PLUGIN_ERROR, VPNC_EDITOR_PLUGIN_ERROR_FAILED,
                             "could not create vpnc object");
                return NULL;
        }
@@ -1017,7 +981,7 @@ nm_vpnc_editor_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, VPNC_PLUGIN_UI_ERROR, VPNC_PLUGIN_UI_ERROR_FAILED,
+               g_set_error (error, VPNC_EDITOR_PLUGIN_ERROR, VPNC_EDITOR_PLUGIN_ERROR_FAILED,
                             "could not load required resources at %s", ui_file);
                g_free (ui_file);
                g_object_unref (object);
@@ -1027,7 +991,7 @@ nm_vpnc_editor_new (NMConnection *connection, GError **error)
 
        priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "vpnc-vbox"));
        if (!priv->widget) {
-               g_set_error (error, VPNC_PLUGIN_UI_ERROR, VPNC_PLUGIN_UI_ERROR_FAILED,
+               g_set_error (error, VPNC_EDITOR_PLUGIN_ERROR, VPNC_EDITOR_PLUGIN_ERROR_FAILED,
                             "could not load UI widget");
                g_object_unref (object);
                return NULL;
diff --git a/properties/nm-vpnc.h b/properties/nm-vpnc.h
index 6ffd148..6749668 100644
--- a/properties/nm-vpnc.h
+++ b/properties/nm-vpnc.h
@@ -23,8 +23,6 @@
 #ifndef _NM_VPNC_H_
 #define _NM_VPNC_H_
 
-#include <glib-object.h>
-
 #define VPNC_TYPE_EDITOR_PLUGIN            (vpnc_editor_plugin_get_type ())
 #define VPNC_EDITOR_PLUGIN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), VPNC_TYPE_EDITOR_PLUGIN, 
VpncEditorPlugin))
 #define VPNC_EDITOR_PLUGIN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), VPNC_TYPE_EDITOR_PLUGIN, 
VpncEditorPluginClass))
diff --git a/properties/tests/Makefile.am b/properties/tests/Makefile.am
index 083ce54..4c9542b 100644
--- a/properties/tests/Makefile.am
+++ b/properties/tests/Makefile.am
@@ -11,7 +11,8 @@ test_import_export_CPPFLAGS = \
        $(LIBNM_CFLAGS) \
        $(LIBNMA_CFLAGS) \
        $(DBUS_CFLAGS) \
-       -I"$(top_srcdir)/shared/"
+       -I"$(top_srcdir)/shared/" \
+       -I"$(top_srcdir)/properties/"
 
 test_import_export_LDADD = \
        $(GTHREAD_LIBS) \
diff --git a/properties/tests/test-import-export.c b/properties/tests/test-import-export.c
index ef224c0..ac2c96e 100644
--- a/properties/tests/test-import-export.c
+++ b/properties/tests/test-import-export.c
@@ -19,21 +19,18 @@
  *
  */
 
+#include "nm-default.h"
+
 #include <string.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <locale.h>
 
-#include <NetworkManager.h>
-#include <nm-utils.h>
-#include <nm-setting-ip4-config.h>
-
-#include <nm-vpn-editor-plugin.h>
+#include "nm-vpnc.h"
+#include "nm-vpnc-helper.h"
 
-#include "../../nm-test-helpers.h"
-#include "../../properties/nm-vpnc.h"
-#include "nm-vpnc-service-defines.h"
-#include "../../properties/nm-vpnc-helper.h"
+#include "nm-test-helpers.h"
+#include "nm-test-utils.h"
 
 typedef struct {
        const char *name;
diff --git a/shared/nm-default.h b/shared/nm-default.h
index c980b02..406c4e9 100644
--- a/shared/nm-default.h
+++ b/shared/nm-default.h
@@ -78,6 +78,11 @@
 #define NM_SETTING_IP_CONFIG_METHOD NM_SETTING_IP4_CONFIG_METHOD
 #define NMSettingIPConfig NMSettingIP4Config
 
+#define nm_setting_ip_config_get_num_routes nm_setting_ip4_config_get_num_routes
+#define nm_setting_ip_config_add_route      nm_setting_ip4_config_add_route
+#define nm_setting_ip_config_get_route      nm_setting_ip4_config_get_route
+#define NM_SETTING_IP_CONFIG_NEVER_DEFAULT  NM_SETTING_IP4_CONFIG_NEVER_DEFAULT
+
 #define VPNC_EDITOR_PLUGIN_ERROR                     NM_SETTING_VPN_ERROR
 #define VPNC_EDITOR_PLUGIN_ERROR_FAILED              NM_SETTING_VPN_ERROR_UNKNOWN
 #define VPNC_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY    NM_SETTING_VPN_ERROR_INVALID_PROPERTY
diff --git a/src/nm-vpnc-service-vpnc-helper.c b/src/nm-vpnc-service-vpnc-helper.c
index 34e39c1..427d093 100644
--- a/src/nm-vpnc-service-vpnc-helper.c
+++ b/src/nm-vpnc-service-vpnc-helper.c
@@ -20,7 +20,8 @@
  * (C) Copyright 2005 Red Hat, Inc.
  */
 
-#include <glib.h>
+#include "nm-default.h"
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -29,10 +30,6 @@
 #include <arpa/inet.h>
 #include <errno.h>
 #include <locale.h>
-#include <NetworkManager.h>
-
-#include "nm-vpnc-service.h"
-#include "nm-utils.h"
 
 static void
 helper_failed (GDBusProxy *proxy, const char *reason)
diff --git a/src/nm-vpnc-service.c b/src/nm-vpnc-service.c
index 5a1c874..c386d08 100644
--- a/src/nm-vpnc-service.c
+++ b/src/nm-vpnc-service.c
@@ -19,7 +19,9 @@
  * (C) Copyright 2007 - 2008 Novell, Inc.
  */
 
-#include <config.h>
+#include "nm-default.h"
+
+#include "nm-vpnc-service.h"
 
 #include <stdio.h>
 #include <string.h>
@@ -32,12 +34,7 @@
 #include <sys/ttydefaults.h>
 #include <errno.h>
 #include <locale.h>
-#include <glib/gi18n.h>
 
-#include <NetworkManager.h>
-#include <nm-utils.h>
-
-#include "nm-vpnc-service.h"
 #include "utils.h"
 
 #if !defined(DIST_VERSION)
diff --git a/src/nm-vpnc-service.h b/src/nm-vpnc-service.h
index f570e09..ba5d0c4 100644
--- a/src/nm-vpnc-service.h
+++ b/src/nm-vpnc-service.h
@@ -22,12 +22,6 @@
 #ifndef NM_VPNC_PLUGIN_H
 #define NM_VPNC_PLUGIN_H
 
-#include <glib.h>
-#include <glib-object.h>
-#include <nm-vpn-service-plugin.h>
-
-#include "nm-vpnc-service-defines.h"
-
 #define NM_TYPE_VPNC_PLUGIN            (nm_vpnc_plugin_get_type ())
 #define NM_VPNC_PLUGIN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPNC_PLUGIN, 
NMVPNCPlugin))
 #define NM_VPNC_PLUGIN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_VPNC_PLUGIN, 
NMVPNCPluginClass))
diff --git a/src/test-vpnc-output.c b/src/test-vpnc-output.c
index e722946..5eefb5e 100644
--- a/src/test-vpnc-output.c
+++ b/src/test-vpnc-output.c
@@ -18,7 +18,10 @@
  * (C) Copyright 2013 Red Hat, Inc.
  */
 
+#include "nm-default.h"
+
 #include <string.h>
+
 #include "utils.h"
 
 #define TEST_HEADER \
diff --git a/src/utils.c b/src/utils.c
index 6fde9d8..cb685b1 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -18,9 +18,12 @@
  * (C) Copyright 2013 Red Hat, Inc.
  */
 
-#include <string.h>
+#include "nm-default.h"
+
 #include "utils.h"
 
+#include <string.h>
+
 #define IS_EOL(a)  (a == '\r' || a == '\n')
 #define VPNC_VERSION_STR "vpnc version "
 
diff --git a/src/utils.h b/src/utils.h
index a2cb49a..d5e2cfd 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -21,8 +21,6 @@
 #ifndef _UTILS_H_
 #define _UTILS_H_
 
-#include <glib.h>
-
 typedef void (*PromptFn) (const char *data, gsize len, gpointer user_data);
 
 gsize utils_handle_output (GString *output,


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