From 7b3078dab5ae53b9de9402c30b44d87277cf2aa9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Thu, 22 Apr 2010 22:42:19 +0200
Subject: Fix AvahiBrowserQuery compilation.


diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct
index 72e989e..844654d 100644
--- a/BuildTools/SCons/SConstruct
+++ b/BuildTools/SCons/SConstruct
@@ -259,7 +259,7 @@ else :
 # Avahi
 if conf.CheckCHeader("avahi-client/client.h") and conf.CheckLib("avahi-client") :
 	env["HAVE_AVAHI"] = True
-	env["AVAHI_FLAGS"] = { "LIBS": ["avahi"] }
+	env["AVAHI_FLAGS"] = { "LIBS": ["avahi-client"] }
 
 conf.Finish()
 
diff --git a/Slimber/CLI/SConscript b/Slimber/CLI/SConscript
index b65843d..87324ad 100644
--- a/Slimber/CLI/SConscript
+++ b/Slimber/CLI/SConscript
@@ -4,5 +4,6 @@ myenv = env.Clone()
 myenv.MergeFlags(env["SLIMBER_FLAGS"])
 myenv.MergeFlags(env["SWIFTEN_FLAGS"])
 myenv.MergeFlags(env["BOOST_FLAGS"])
+myenv.MergeFlags(env["AVAHI_FLAGS"])
 
 myenv.Program("slimber", ["main.cpp"])
diff --git a/Slimber/Qt/SConscript b/Slimber/Qt/SConscript
index c2e203c..9b0a8db 100644
--- a/Slimber/Qt/SConscript
+++ b/Slimber/Qt/SConscript
@@ -10,6 +10,7 @@ myenv.MergeFlags(env["LIBIDN_FLAGS"])
 myenv.MergeFlags(env["BOOST_FLAGS"])
 myenv.MergeFlags(env.get("LIBXML_FLAGS", ""))
 myenv.MergeFlags(env.get("EXPAT_FLAGS", ""))
+myenv.MergeFlags(env.get("AVAHI_FLAGS", ""))
 
 myenv.Tool("qt4", toolpath = ["#/BuildTools/SCons/Tools"])
 myenv.Tool("nsis", toolpath = ["#/BuildTools/SCons/Tools"])
diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiBrowseQuery.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiBrowseQuery.h
index cca0475..4b8987f 100644
--- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiBrowseQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiBrowseQuery.h
@@ -17,14 +17,15 @@ namespace Swift {
 
 	class AvahiBrowseQuery : public DNSSDBrowseQuery, public AvahiQuery {
 		public:	
-			AvahiBrowseQuery(boost::shared_ptr<AvahiQuerier> q) : AvahiQuery(q) {
+			AvahiBrowseQuery(boost::shared_ptr<AvahiQuerier> q) : AvahiQuery(q), browser(NULL) {
 			}
 
 			void startBrowsing() {
+				assert(!browser);
 				std::cout << "Start browsing" << std::endl;
 				avahi_threaded_poll_lock(querier->getThreadedPoll());
 				std::cout << "Creating browser" << std::endl;
-				AvahiServiceBrowser* browser = avahi_service_browser_new(querier->getClient(), AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_presence._tcp", NULL, (AvahiLookupFlags) 0, &handleServiceDiscoveredStatic, this);
+				browser = avahi_service_browser_new(querier->getClient(), AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_presence._tcp", NULL, (AvahiLookupFlags) 0, &handleServiceDiscoveredStatic, this);
 				if (!browser) {
 					std::cout << "Error" << std::endl;
 					MainEventLoop::postEvent(boost::bind(boost::ref(onError)), shared_from_this());
@@ -35,9 +36,8 @@ namespace Swift {
 			}
 
 			void stopBrowsing() {
-				assert(browser);
 				avahi_threaded_poll_lock(querier->getThreadedPoll());
-				avahi_server_browser_free(browser);
+				avahi_service_browser_free(browser);
 				browser = NULL;
 				avahi_threaded_poll_unlock(querier->getThreadedPoll());
 			}
@@ -70,5 +70,9 @@ namespace Swift {
 						break;
 				}
 			}
+
+		private:
+			AvahiServiceBrowser* browser;
+			
 	};
 }
diff --git a/Swiften/LinkLocal/SConscript b/Swiften/LinkLocal/SConscript
index b929db1..3d4d737 100644
--- a/Swiften/LinkLocal/SConscript
+++ b/Swiften/LinkLocal/SConscript
@@ -28,6 +28,7 @@ if myenv.get("HAVE_BONJOUR", 0) :
 			"DNSSD/Bonjour/BonjourQuery.cpp",
 		]
 elif myenv.get("HAVE_AVAHI", 0) :
+	myenv.Append(CPPDEFINES = ["HAVE_AVAHI"])
 	sources += [
 			"DNSSD/Avahi/AvahiQuerier.cpp",
 			"DNSSD/Avahi/AvahiQuery.cpp"
-- 
cgit v0.10.2-6-g49f6