[network-manager-fortisslvpn/th/gtk-split-and-log-bgo771544: 9/26] all: use "nm-default.h" header



commit aaf6167f4ce1f25294d27c34ffbfc9a1bc00a824
Author: Thomas Haller <thaller redhat com>
Date:   Thu Sep 15 09:35:01 2016 +0200

    all: use "nm-default.h" header

 auth-dialog/Makefile.am                            |    3 +-
 auth-dialog/main.c                                 |    8 +-
 properties/Makefile.am                             |   53 ++++++---
 properties/nm-fortisslvpn.c                        |   34 +-----
 properties/nm-fortisslvpn.h                        |    4 +-
 shared/Makefile.am                                 |    2 +
 shared/nm-default.h                                |  135 ++++++++++++++++++++
 .../nm-service-defines.h                           |    6 +-
 src/Makefile.am                                    |   10 +-
 src/nm-fortisslvpn-pppd-plugin.c                   |   15 +-
 src/nm-fortisslvpn-service.c                       |   13 +--
 src/nm-fortisslvpn-service.h                       |    7 -
 12 files changed, 203 insertions(+), 87 deletions(-)
---
diff --git a/auth-dialog/Makefile.am b/auth-dialog/Makefile.am
index 9ef8a9e..7e36c89 100644
--- a/auth-dialog/Makefile.am
+++ b/auth-dialog/Makefile.am
@@ -6,7 +6,8 @@ nm_fortisslvpn_auth_dialog_CPPFLAGS = \
        $(GTK_CFLAGS) \
        $(LIBNMA_CFLAGS) \
        $(LIBSECRET_CFLAGS) \
-       -I$(top_srcdir) \
+       "-I$(top_srcdir)" \
+       "-I$(top_srcdir)/shared" \
        -DUIDIR=\""$(uidir)"\"
 
 nm_fortisslvpn_auth_dialog_SOURCES = \
diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index 38399a3..0eff70f 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -19,22 +19,16 @@
  * (C) Copyright 2008 - 2011 Red Hat, Inc.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "nm-default.h"
 
 #include <string.h>
 #include <stdlib.h>
 #include <errno.h>
-#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <libsecret/secret.h>
 
-#include <NetworkManager.h>
 #include <nma-vpn-password-dialog.h>
 
-#include "src/nm-fortisslvpn-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 de576f8..d6c9269 100644
--- a/properties/Makefile.am
+++ b/properties/Makefile.am
@@ -5,49 +5,70 @@ if WITH_LIBNM_GLIB
 plugin_LTLIBRARIES += libnm-fortisslvpn-properties.la
 endif
 
-libnm_vpn_plugin_fortisslvpn_la_SOURCES = \
+shared_sources = \
+       $(top_srcdir)/shared/nm-service-defines.h \
+       $(NULL)
+
+plugin_sources = \
        nm-fortisslvpn.c \
        nm-fortisslvpn.h
 
-libnm_fortisslvpn_properties_la_SOURCES = \
-       $(libnm_vpn_plugin_fortisslvpn_la_SOURCES)
-
 uidir = $(datadir)/gnome-vpn-properties/fortisslvpn
 ui_DATA = nm-fortisslvpn-dialog.ui
 
 common_CFLAGS = \
        $(GLIB_CFLAGS) \
-       $(GTK_CFLAGS) \
-       -I$(top_srcdir) \
+       "-I$(top_srcdir)/" \
+       "-I$(top_srcdir)/shared/" \
        -DUIDIR=\""$(uidir)"\" \
        -DLOCALEDIR=\""$(datadir)/locale"\"
 
+###############################################################################
+
+libnm_vpn_plugin_fortisslvpn_la_SOURCES = \
+       $(shared_sources) \
+       $(plugin_sources)
+
 libnm_vpn_plugin_fortisslvpn_la_CFLAGS = \
+       -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB \
+       $(common_CFLAGS) \
+       $(GTK_CFLAGS) \
        $(LIBNM_CFLAGS) \
        $(LIBNMA_CFLAGS) \
-       $(common_CFLAGS)
-
-libnm_fortisslvpn_properties_la_CFLAGS = \
-       -DNM_VPN_OLD \
-       $(LIBNM_GLIB_CFLAGS) \
-       $(LIBNM_GTK_CFLAGS) \
-       $(common_CFLAGS)
+       $(NULL)
 
 libnm_vpn_plugin_fortisslvpn_la_LIBADD = \
        $(GTK_LIBS) \
        $(LIBNM_LIBS) \
        $(LIBNMA_LIBS)
 
+libnm_vpn_plugin_fortisslvpn_la_LDFLAGS = \
+       -avoid-version
+
+###############################################################################
+
+libnm_fortisslvpn_properties_la_SOURCES = \
+       $(shared_sources) \
+       $(plugin_sources)
+
+libnm_fortisslvpn_properties_la_CFLAGS = \
+       -DNM_VPN_OLD \
+       -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB \
+       $(common_CFLAGS) \
+       $(GTK_CFLAGS) \
+       $(LIBNM_GLIB_CFLAGS) \
+       $(LIBNM_GTK_CFLAGS) \
+       $(NULL)
+
 libnm_fortisslvpn_properties_la_LIBADD = \
        $(GTK_LIBS) \
        $(LIBNM_GLIB_LIBS) \
        $(LIBNM_GTK_LIBS)
 
-libnm_vpn_plugin_fortisslvpn_la_LDFLAGS = \
+libnm_fortisslvpn_properties_la_LDFLAGS = \
        -avoid-version
 
-libnm_fortisslvpn_properties_la_LDFLAGS = \
-       $(libnm_vpn_plugin_fortisslvpn_la_LDFLAGS)
+###############################################################################
 
 CLEANFILES = *.bak *~
 
diff --git a/properties/nm-fortisslvpn.c b/properties/nm-fortisslvpn.c
index 3ec13fc..6dcf3c5 100644
--- a/properties/nm-fortisslvpn.c
+++ b/properties/nm-fortisslvpn.c
@@ -22,45 +22,17 @@
  *
  **************************************************************************/
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "nm-default.h"
+
+#include "nm-fortisslvpn.h"
 
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <errno.h>
 #include <stdlib.h>
-#include <glib/gi18n-lib.h>
 #include <string.h>
 #include <gtk/gtk.h>
 
-#ifdef NM_VPN_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 <nm-ui-utils.h>
-
-#define NMV_EDITOR_PLUGIN_ERROR                     NM_SETTING_VPN_ERROR
-#define NMV_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY    NM_SETTING_VPN_ERROR_INVALID_PROPERTY
-
-#define nm_simple_connection_new nm_connection_new
-
-#else /* !NM_VPN_OLD */
-
-#include <NetworkManager.h>
-#include <nma-ui-utils.h>
-
-#define NMV_EDITOR_PLUGIN_ERROR                     NM_CONNECTION_ERROR
-#define NMV_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY    NM_CONNECTION_ERROR_INVALID_PROPERTY
-
-#endif
-
-#include "src/nm-fortisslvpn-service-defines.h"
-#include "nm-fortisslvpn.h"
-
 #define FORTISSLVPN_PLUGIN_NAME    _("Fortinet SSLVPN")
 #define FORTISSLVPN_PLUGIN_DESC    _("Compatible with Fortinet SSLVPN servers.")
 #define FORTISSLVPN_PLUGIN_SERVICE NM_DBUS_SERVICE_FORTISSLVPN
diff --git a/properties/nm-fortisslvpn.h b/properties/nm-fortisslvpn.h
index e87f545..1b22657 100644
--- a/properties/nm-fortisslvpn.h
+++ b/properties/nm-fortisslvpn.h
@@ -23,8 +23,6 @@
 #ifndef _NM_FORTISSLVPN_H_
 #define _NM_FORTISSLVPN_H_
 
-#include <glib-object.h>
-
 #define FORTISSLVPN_TYPE_EDITOR_PLUGIN            (fortisslvpn_editor_plugin_get_type ())
 #define FORTISSLVPN_EDITOR_PLUGIN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
FORTISSLVPN_TYPE_EDITOR_PLUGIN, FortisslvpnEditorPlugin))
 #define FORTISSLVPN_EDITOR_PLUGIN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), 
FORTISSLVPN_TYPE_EDITOR_PLUGIN, FortisslvpnEditorPluginClass))
@@ -66,5 +64,5 @@ struct _FortisslvpnEditorClass {
 
 GType fortisslvpn_editor_get_type (void);
 
-#endif /* _NM_FORTISSLVPN_H_ */
+#endif /* _NM_FORTISSLVPN_H_ */
 
diff --git a/shared/Makefile.am b/shared/Makefile.am
index 098cd17..8634c82 100644
--- a/shared/Makefile.am
+++ b/shared/Makefile.am
@@ -6,4 +6,6 @@ EXTRA_DIST = \
        nm-utils/nm-shared-utils.c \
        nm-utils/nm-shared-utils.h \
        nm-utils/nm-vpn-plugin-macros.h \
+       nm-default.h \
+       nm-service-defines.h \
        $(NULL)
diff --git a/shared/nm-default.h b/shared/nm-default.h
new file mode 100644
index 0000000..64bd85a
--- /dev/null
+++ b/shared/nm-default.h
@@ -0,0 +1,135 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager -- Network link manager
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2015 Red Hat, Inc.
+ */
+
+#ifndef __NM_DEFAULT_H__
+#define __NM_DEFAULT_H__
+
+/* makefiles define NETWORKMANAGER_COMPILATION for compiling NetworkManager.
+ * Depending on which parts are compiled, different values are set. */
+#define NM_NETWORKMANAGER_COMPILATION_DEFAULT             0x0001
+#define NM_NETWORKMANAGER_COMPILATION_LIB_BASE            0x0002
+#define NM_NETWORKMANAGER_COMPILATION_LIB_EDITOR          0x0004
+#define NM_NETWORKMANAGER_COMPILATION_LIB                 (0x0002 | 0x0004)
+
+#ifndef NETWORKMANAGER_COMPILATION
+/* For convenience, we don't require our Makefile.am to define
+ * -DNETWORKMANAGER_COMPILATION. As we now include this internal header,
+ *  we know we do a NETWORKMANAGER_COMPILATION. */
+#define NETWORKMANAGER_COMPILATION NM_NETWORKMANAGER_COMPILATION_DEFAULT
+#endif
+
+/*****************************************************************************/
+
+/* always include these headers for our internal source files. */
+
+#ifndef ___CONFIG_H__
+#define ___CONFIG_H__
+#include <config.h>
+#endif
+
+/* always include these headers for our internal source files. */
+
+#include "nm-utils/nm-glib.h"
+#include "nm-utils/gsystem-local-alloc.h"
+#include "nm-utils/nm-macros-internal.h"
+
+#include "nm-version.h"
+#include "nm-service-defines.h"
+
+/*****************************************************************************/
+
+#if ((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_LIB)
+
+#include <glib/gi18n-lib.h>
+
+#else
+
+#include <glib/gi18n.h>
+
+#endif /* NM_NETWORKMANAGER_COMPILATION_LIB */
+
+/*****************************************************************************/
+
+#ifdef NM_VPN_OLD
+
+#define NM_VPN_LIBNM_COMPAT
+#include <nm-connection.h>
+#include <nm-setting-connection.h>
+#include <nm-setting-8021x.h>
+#include <nm-setting-ip4-config.h>
+#include <nm-setting-vpn.h>
+#include <nm-utils.h>
+#include <nm-vpn-plugin-ui-interface.h>
+
+#define nm_simple_connection_new nm_connection_new
+#define NM_SETTING_IP_CONFIG NM_SETTING_IP4_CONFIG
+#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_get_num_addresses      nm_setting_ip4_config_get_num_addresses
+#define nm_setting_ip_config_get_num_dns_searches   nm_setting_ip4_config_get_num_dns_searches
+#define nm_setting_ip_config_get_never_default      nm_setting_ip4_config_get_never_default
+#define nm_setting_ip_config_get_dhcp_hostname      nm_setting_ip4_config_get_dhcp_hostname
+#define nm_setting_ip_config_get_method             nm_setting_ip4_config_get_method
+#define nm_setting_ip_config_get_dhcp_hostname      nm_setting_ip4_config_get_dhcp_hostname
+#define nm_setting_ip_config_get_num_dns            nm_setting_ip4_config_get_num_dns
+#define NM_SETTING_IP_CONFIG_NEVER_DEFAULT          NM_SETTING_IP4_CONFIG_NEVER_DEFAULT
+
+#define NMV_EDITOR_PLUGIN_ERROR                     NM_SETTING_VPN_ERROR
+#define NMV_EDITOR_PLUGIN_ERROR_FAILED              NM_SETTING_VPN_ERROR_UNKNOWN
+#define NMV_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY    NM_SETTING_VPN_ERROR_INVALID_PROPERTY
+#define NMV_EDITOR_PLUGIN_ERROR_MISSING_PROPERTY    NM_SETTING_VPN_ERROR_MISSING_PROPERTY
+#define NMV_EDITOR_PLUGIN_ERROR_FILE_NOT_VPN        NM_SETTING_VPN_ERROR_UNKNOWN
+#define NMV_EDITOR_PLUGIN_ERROR_FILE_NOT_READABLE   NM_SETTING_VPN_ERROR_UNKNOWN
+#define NMV_EDITOR_PLUGIN_ERROR_FILE_INVALID        NM_SETTING_VPN_ERROR_UNKNOWN
+
+#else /* !NM_VPN_OLD */
+
+#include <NetworkManager.h>
+
+#define NMV_EDITOR_PLUGIN_ERROR                     NM_CONNECTION_ERROR
+#define NMV_EDITOR_PLUGIN_ERROR_FAILED              NM_CONNECTION_ERROR_FAILED
+#define NMV_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY    NM_CONNECTION_ERROR_INVALID_PROPERTY
+#define NMV_EDITOR_PLUGIN_ERROR_MISSING_PROPERTY    NM_CONNECTION_ERROR_MISSING_PROPERTY
+#define NMV_EDITOR_PLUGIN_ERROR_FILE_NOT_VPN        NM_CONNECTION_ERROR_FAILED
+#define NMV_EDITOR_PLUGIN_ERROR_FILE_NOT_READABLE   NM_CONNECTION_ERROR_FAILED
+#define NMV_EDITOR_PLUGIN_ERROR_FILE_INVALID        NM_CONNECTION_ERROR_FAILED
+
+#endif /* NM_VPN_OLD */
+
+/*****************************************************************************/
+
+#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_LIB_EDITOR
+
+#ifdef NM_VPN_OLD
+#include <nm-ui-utils.h>
+#else /* NM_VPN_OLD */
+#include <nma-ui-utils.h>
+#endif /* NM_VPN_OLD */
+
+#endif /* NM_NETWORKMANAGER_COMPILATION_LIB_EDITOR */
+
+/*****************************************************************************/
+
+#endif /* __NM_DEFAULT_H__ */
diff --git a/src/nm-fortisslvpn-service-defines.h b/shared/nm-service-defines.h
similarity index 93%
rename from src/nm-fortisslvpn-service-defines.h
rename to shared/nm-service-defines.h
index 7e707c0..3d67988 100644
--- a/src/nm-fortisslvpn-service-defines.h
+++ b/shared/nm-service-defines.h
@@ -21,8 +21,8 @@
  * (C) Copyright 2015 Lubomir Rintel
  */
 
-#ifndef NM_FORTISSLVPN_SERVICE_DEFINES_H
-#define NM_FORTISSLVPN_SERVICE_DEFINES_H
+#ifndef __NM_SERVICE_DEFINES_H__
+#define __NM_SERVICE_DEFINES_H__
 
 /* For the NM <-> VPN plugin service */
 #define NM_DBUS_SERVICE_FORTISSLVPN    "org.freedesktop.NetworkManager.fortisslvpn"
@@ -37,4 +37,4 @@
 #define NM_FORTISSLVPN_KEY_KEY               "key"
 #define NM_FORTISSLVPN_KEY_TRUSTED_CERT      "trusted-cert"
 
-#endif /* NM_FORTISSLVPN_PLUGIN_H */
+#endif /* __NM_SERVICE_DEFINES_H__ */
diff --git a/src/Makefile.am b/src/Makefile.am
index 8d18d27..e820797 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,7 +6,8 @@ install-data-hook:
 AM_CPPFLAGS = \
        $(GLIB_CFLAGS) \
        $(LIBNM_CFLAGS) \
-       -I$(top_srcdir) \
+       "-I$(top_srcdir)/" \
+       "-I$(top_srcdir)/shared/" \
        -DNM_FORTISSLVPN_LOCALEDIR=\"$(datadir)/locale\" \
        -DNM_FORTISSLVPN_STATEDIR=\"$(fortisslvpn_statedir)\" \
        -DPLUGINDIR=\"$(PPPD_PLUGIN_DIR)\"
@@ -14,8 +15,8 @@ AM_CPPFLAGS = \
 libexec_PROGRAMS = nm-fortisslvpn-service
 
 nm_fortisslvpn_service_SOURCES = \
+       $(top_srcdir)/shared/nm-service-defines.h \
        nm-fortisslvpn-service.c \
-       nm-fortisslvpn-service-defines.h \
        nm-fortisslvpn-service.h
 
 # D-Bus stuff
@@ -51,7 +52,10 @@ nm_fortisslvpn_pppd_plugin_la_SOURCES = \
 
 nm_fortisslvpn_pppd_plugin_la_CPPFLAGS = \
        $(GLIB_CFLAGS) \
-       $(LIBNM_CFLAGS)
+       $(LIBNM_CFLAGS) \
+       "-I$(top_srcdir)/" \
+       "-I$(top_srcdir)/shared/" \
+       $(NULL)
 
 nm_fortisslvpn_pppd_plugin_la_LDFLAGS = -module -avoid-version
 
diff --git a/src/nm-fortisslvpn-pppd-plugin.c b/src/nm-fortisslvpn-pppd-plugin.c
index 9f00813..37dd378 100644
--- a/src/nm-fortisslvpn-pppd-plugin.c
+++ b/src/nm-fortisslvpn-pppd-plugin.c
@@ -20,23 +20,26 @@
  *
  */
 
-#include <string.h>
+#define ___CONFIG_H__
+#include <config.h>
+
 #include <pppd/pppd.h>
 #include <pppd/fsm.h>
 #include <pppd/ipcp.h>
+
+#include "nm-default.h"
+
+#include <string.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <dlfcn.h>
-#include <glib.h>
 #include <stdlib.h>
 
 #include "nm-fortisslvpn-pppd-service-dbus.h"
 #include "nm-fortisslvpn-service.h"
 #include "nm-ppp-status.h"
 
-#include <nm-utils.h>
-
 int plugin_init (void);
 
 char pppd_version[] = VERSION;
@@ -297,9 +300,7 @@ plugin_init (void)
        GError *err = NULL;
        const char *bus_name;
 
-#if !GLIB_CHECK_VERSION (2, 35, 0)
-       g_type_init ();
-#endif
+       nm_g_type_init ();
 
        bus_name = getenv ("NM_DBUS_SERVICE_FORTISSLVPN");
        if (!bus_name)
diff --git a/src/nm-fortisslvpn-service.c b/src/nm-fortisslvpn-service.c
index b95e6ae..f03e6db 100644
--- a/src/nm-fortisslvpn-service.c
+++ b/src/nm-fortisslvpn-service.c
@@ -21,9 +21,9 @@
  * (C) Copyright 2015 Lubomir Rintel
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "nm-default.h"
+
+#include "nm-fortisslvpn-service.h"
 
 #include <stdio.h>
 #include <string.h>
@@ -37,11 +37,8 @@
 #include <locale.h>
 #include <errno.h>
 
-#include <glib.h>
 #include <glib/gstdio.h>
-#include <glib/gi18n.h>
 
-#include "nm-fortisslvpn-service.h"
 #include "nm-ppp-status.h"
 #include "nm-fortisslvpn-pppd-service-dbus.h"
 
@@ -756,9 +753,7 @@ main (int argc, char *argv[])
                {NULL}
        };
 
-#if !GLIB_CHECK_VERSION (2, 35, 0)
-       g_type_init ();
-#endif
+       nm_g_type_init ();
 
        /* locale will be set according to environment LC_* variables */
        setlocale (LC_ALL, "");
diff --git a/src/nm-fortisslvpn-service.h b/src/nm-fortisslvpn-service.h
index 074847e..ad29a6c 100644
--- a/src/nm-fortisslvpn-service.h
+++ b/src/nm-fortisslvpn-service.h
@@ -24,13 +24,6 @@
 #ifndef NM_FORTISSLVPN_SERVICE_H
 #define NM_FORTISSLVPN_SERVICE_H
 
-#include <glib.h>
-#include <glib-object.h>
-
-#include <NetworkManager.h>
-
-#include "nm-fortisslvpn-service-defines.h"
-
 #define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
 
 /* For the pppd plugin <-> VPN plugin service */


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