From 518214ee85e10c5bc99d3b115ae7ac9cc3fc14fc Mon Sep 17 00:00:00 2001
From: Alexandre Rostovtsev <tetromino@gentoo.org>
Date: Mon, 29 Apr 2013 23:02:25 -0400
Subject: [PATCH] Avoid build-time dependency on NetworkManager

Needed to prevent a dependency loop:
nm -> libsoup -> glib-networking -> libproxy -> nm

https://bugs.gentoo.org/467696
---
 libproxy/cmake/modules/network_networkmanager.cmk |  4 ++--
 libproxy/modules/network_networkmanager.cpp       | 21 ++++++++++++++++++++-
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/libproxy/cmake/modules/network_networkmanager.cmk b/libproxy/cmake/modules/network_networkmanager.cmk
index d9f9588..2586bbd 100644
--- a/libproxy/cmake/modules/network_networkmanager.cmk
+++ b/libproxy/cmake/modules/network_networkmanager.cmk
@@ -1,3 +1,3 @@
 if (NOT WIN32 AND NOT APPLE)
-  px_check_modules(NM NetworkManager dbus-1)
-endif()
\ No newline at end of file
+  px_check_modules(NM dbus-1)
+endif()
diff --git a/libproxy/modules/network_networkmanager.cpp b/libproxy/modules/network_networkmanager.cpp
index 564c275..a03425b 100644
--- a/libproxy/modules/network_networkmanager.cpp
+++ b/libproxy/modules/network_networkmanager.cpp
@@ -23,7 +23,26 @@
 using namespace libproxy;
 
 #include <dbus/dbus.h>
-#include <NetworkManager/NetworkManager.h>
+
+
+/*
+ * copy-pasted from NetworkManager-0.9.6.4's NetworkManager.h to prevent
+ * a circular dependency; https://bugs.gentoo.org/467696
+ */
+#define	NM_DBUS_PATH                        "/org/freedesktop/NetworkManager"
+#define	NM_DBUS_INTERFACE                   "org.freedesktop.NetworkManager"
+typedef enum {
+	NM_STATE_UNKNOWN          = 0,
+	NM_STATE_ASLEEP           = 10,
+	NM_STATE_DISCONNECTED     = 20,
+	NM_STATE_DISCONNECTING    = 30,
+	NM_STATE_CONNECTING       = 40,
+	NM_STATE_CONNECTED_LOCAL  = 50,
+	NM_STATE_CONNECTED_SITE   = 60,
+	NM_STATE_CONNECTED_GLOBAL = 70
+} NMState;
+#define NM_STATE_CONNECTED NM_STATE_CONNECTED_GLOBAL
+
 
 class networkmanager_network_extension : public network_extension {
 public:
-- 
1.8.2.1

