[network-manager-applet/th/proxy: 5/5] WIP: proxy: add compatibility for building against libnm-1-4 without proxy support



commit 1daaf4984fdbe3df70ce1b7c05620df3d7aef566
Author: Thomas Haller <thaller redhat com>
Date:   Tue Oct 4 15:00:47 2016 +0200

    WIP: proxy: add compatibility for building against libnm-1-4 without proxy support

 shared/nm-libnm-compat.h                     |    9 +++++++++
 src/connection-editor/nm-connection-editor.c |    4 ++++
 src/connection-editor/nm-connection-list.c   |    4 ++++
 src/connection-editor/page-proxy.c           |   10 +++++++++-
 src/connection-editor/page-proxy.h           |    7 ++++---
 5 files changed, 30 insertions(+), 4 deletions(-)
---
diff --git a/shared/nm-libnm-compat.h b/shared/nm-libnm-compat.h
index 7023cb3..d2579b9 100644
--- a/shared/nm-libnm-compat.h
+++ b/shared/nm-libnm-compat.h
@@ -22,4 +22,13 @@
 #ifndef __NM_LIBNM_COMPAT_H__
 #define __NM_LIBNM_COMPAT_H__
 
+#define NM_LIBNM_COMPAT_UNDEPRECATE(cmd) \
+       ({ \
+               G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
+               (cmd); \
+               G_GNUC_END_IGNORE_DEPRECATIONS \
+       })
+
+#define NM_LIBNM_COMPAT_PROXY_SUPPORTED (NM_CHECK_VERSION (1, 5, 0))
+
 #endif /* __NM_LIBNM_COMPAT_H__ */
diff --git a/src/connection-editor/nm-connection-editor.c b/src/connection-editor/nm-connection-editor.c
index 0a7416e..c3e5753 100644
--- a/src/connection-editor/nm-connection-editor.c
+++ b/src/connection-editor/nm-connection-editor.c
@@ -831,9 +831,13 @@ nm_connection_editor_set_connection (NMConnectionEditor *editor,
                        goto out;
        }
 
+#if NM_LIBNM_COMPAT_PROXY_SUPPORTED
+       G_GNUC_BEGIN_IGNORE_DEPRECATIONS
        if (   nm_connection_get_setting_proxy (editor->connection)
            && !add_page (editor, ce_page_proxy_new, editor->connection, error))
                goto out;
+       G_GNUC_END_IGNORE_DEPRECATIONS
+#endif
        if (   nm_connection_get_setting_ip4_config (editor->connection)
            && !add_page (editor, ce_page_ip4_new, editor->connection, error))
                goto out;
diff --git a/src/connection-editor/nm-connection-list.c b/src/connection-editor/nm-connection-list.c
index 85173fc..6256479 100644
--- a/src/connection-editor/nm-connection-list.c
+++ b/src/connection-editor/nm-connection-list.c
@@ -277,8 +277,12 @@ really_add_connection (NMConnection *connection,
                return;
        }
 
+#if NM_LIBNM_COMPAT_PROXY_SUPPORTED
+       G_GNUC_BEGIN_IGNORE_DEPRECATIONS
        if (connection_supports_proxy (connection) && !nm_connection_get_setting_proxy (connection))
                nm_connection_add_setting (connection, nm_setting_proxy_new ());
+       G_GNUC_END_IGNORE_DEPRECATIONS
+#endif
        if (connection_supports_ip4 (connection) && !nm_connection_get_setting_ip4_config (connection))
                nm_connection_add_setting (connection, nm_setting_ip4_config_new ());
        if (connection_supports_ip6 (connection) && !nm_connection_get_setting_ip6_config (connection))
diff --git a/src/connection-editor/page-proxy.c b/src/connection-editor/page-proxy.c
index 8711f9d..015dd5b 100644
--- a/src/connection-editor/page-proxy.c
+++ b/src/connection-editor/page-proxy.c
@@ -18,13 +18,19 @@
  * (C) Copyright 2016 Atul Anand <atulhjp gmail com>.
  */
 
+#undef NM_VERSION_MAX_ALLOWED
+#define NM_VERSION_MAX_ALLOWED NM_VERSION_1_6
+
 #include "nm-default.h"
 
+#if NM_LIBNM_COMPAT_PROXY_SUPPORTED
+
+#include "page-proxy.h"
+
 #include <string.h>
 #include <errno.h>
 #include <stdlib.h>
 
-#include "page-proxy.h"
 #include "nm-connection-editor.h"
 
 G_DEFINE_TYPE (CEPageProxy, ce_page_proxy, CE_TYPE_PAGE)
@@ -484,3 +490,5 @@ ce_page_proxy_class_init (CEPageProxyClass *proxy_class)
        /* virtual methods */
        parent_class->ce_page_validate_v = ce_page_validate_v;
 }
+
+#endif /* NM_LIBNM_COMPAT_PROXY_SUPPORTED */
diff --git a/src/connection-editor/page-proxy.h b/src/connection-editor/page-proxy.h
index dc78185..9e5afb3 100644
--- a/src/connection-editor/page-proxy.h
+++ b/src/connection-editor/page-proxy.h
@@ -21,11 +21,10 @@
 #ifndef __PAGE_PROXY_H__
 #define __PAGE_PROXY_H__
 
-#include <glib.h>
-#include <glib-object.h>
-
 #include "ce-page.h"
 
+#if NM_LIBNM_COMPAT_PROXY_SUPPORTED
+
 #define CE_TYPE_PAGE_PROXY            (ce_page_proxy_get_type ())
 #define CE_PAGE_PROXY(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CE_TYPE_PAGE_PROXY, CEPageProxy))
 #define CE_PAGE_PROXY_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), CE_TYPE_PAGE_PROXY, 
CEPageProxyClass))
@@ -50,4 +49,6 @@ CEPage *ce_page_proxy_new (NMConnectionEditor *editor,
                            const char **out_secrets_setting_name,
                            GError **error);
 
+#endif /* NM_LIBNM_COMPAT_PROXY_SUPPORTED */
+
 #endif  /* __PAGE_PROXY_H__ */


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