From 1873eca1f2147fa18f03fdd849fdd73d1a012be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Wed, 5 Aug 2009 18:58:24 +0200 Subject: Slimber: Use DNSSD factory. diff --git a/Slimber/MainController.cpp b/Slimber/MainController.cpp index baf032c..c8c2ad1 100644 --- a/Slimber/MainController.cpp +++ b/Slimber/MainController.cpp @@ -8,7 +8,7 @@ #include "Swiften/Application/Platform/PlatformApplication.h" #include "Swiften/LinkLocal/LinkLocalService.h" #include "Swiften/LinkLocal/LinkLocalServiceBrowser.h" -#include "Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h" +#include "Swiften/LinkLocal/DNSSD/PlatformDNSSDQuerierFactory.h" #include "Slimber/Server.h" #include "Slimber/FileVCardCollection.h" #include "Slimber/MenuletController.h" @@ -21,7 +21,11 @@ MainController::MainController(Menulet* menulet) : menulet(menulet) { menuletController->onRestartRequested.connect(boost::bind( &MainController::handleRestartRequested, this)); - dnsSDQuerier = boost::shared_ptr(new BonjourQuerier()); + dnsSDQuerier = PlatformDNSSDQuerierFactory().createQuerier(); + if (!dnsSDQuerier) { + // TODO + assert(false); + } linkLocalServiceBrowser = new LinkLocalServiceBrowser(dnsSDQuerier); linkLocalServiceBrowser->onServiceAdded.connect( diff --git a/Swiften/LinkLocal/DNSSD/Makefile.inc b/Swiften/LinkLocal/DNSSD/Makefile.inc index f6997ef..4b014f3 100644 --- a/Swiften/LinkLocal/DNSSD/Makefile.inc +++ b/Swiften/LinkLocal/DNSSD/Makefile.inc @@ -4,7 +4,8 @@ SWIFTEN_SOURCES += \ Swiften/LinkLocal/DNSSD/DNSSDBrowseQuery.cpp \ Swiften/LinkLocal/DNSSD/DNSSDRegisterQuery.cpp \ Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.cpp \ - Swiften/LinkLocal/DNSSD/DNSSDResolveHostnameQuery.cpp + Swiften/LinkLocal/DNSSD/DNSSDResolveHostnameQuery.cpp \ + Swiften/LinkLocal/DNSSD/PlatformDNSSDQuerierFactory.cpp ifeq ($(HAVE_BONJOUR),yes) include Swiften/LinkLocal/DNSSD/Bonjour/Makefile.inc diff --git a/Swiften/LinkLocal/DNSSD/PlatformDNSSDQuerierFactory.cpp b/Swiften/LinkLocal/DNSSD/PlatformDNSSDQuerierFactory.cpp new file mode 100644 index 0000000..e704b72 --- /dev/null +++ b/Swiften/LinkLocal/DNSSD/PlatformDNSSDQuerierFactory.cpp @@ -0,0 +1,25 @@ +#include "Swiften/LinkLocal/DNSSD/PlatformDNSSDQuerierFactory.h" + +#ifdef HAVE_SWIFTEN_CONFIG_H +#include "Swiften/config.h" +#endif +#if defined(HAVE_BONJOUR) +#include "Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h" +#elif defined(HAVE_AVAHI) +#include "Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h" +#endif + + +namespace Swift { + +boost::shared_ptr PlatformDNSSDQuerierFactory::createQuerier() { +#if defined(HAVE_BONJOUR) + return boost::shared_ptr(new BonjourQuerier()); +#elif defined(HAVE_AVAHI) + return boost::shared_ptr(new AvahiQuerier()); +#else + return boost::shared_ptr(); +#endif +} + +} diff --git a/Swiften/LinkLocal/DNSSD/PlatformDNSSDQuerierFactory.h b/Swiften/LinkLocal/DNSSD/PlatformDNSSDQuerierFactory.h new file mode 100644 index 0000000..b52814b --- /dev/null +++ b/Swiften/LinkLocal/DNSSD/PlatformDNSSDQuerierFactory.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace Swift { + class DNSSDQuerier; + + class PlatformDNSSDQuerierFactory { + public: + boost::shared_ptr createQuerier(); + }; +} -- cgit v0.10.2-6-g49f6