diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-10-27 19:06:56 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-10-27 19:07:55 (GMT) |
commit | 6810a2896f27e7ee07aee847f5e8dbccd1f6ec89 (patch) | |
tree | f7ea87f030e57cb4494a4f897506fb18fc3d2241 /Swiften/LinkLocal/DNSSD/Fake | |
parent | a7da393cfc807048d320ddba8a1c7d24ef23a46e (diff) | |
download | swift-6810a2896f27e7ee07aee847f5e8dbccd1f6ec89.zip swift-6810a2896f27e7ee07aee847f5e8dbccd1f6ec89.tar.bz2 |
Remove MainEventLoop singleton.
The event loop now needs to be explicitly passed to clients
using it.
Diffstat (limited to 'Swiften/LinkLocal/DNSSD/Fake')
-rw-r--r-- | Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp | 24 | ||||
-rw-r--r-- | Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h | 4 |
2 files changed, 15 insertions, 13 deletions
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp index d8e7acf..0bcdba1 100644 --- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp +++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp @@ -12,11 +12,11 @@ #include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h" #include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveServiceQuery.h" #include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveHostnameQuery.h" -#include "Swiften/EventLoop/MainEventLoop.h" +#include "Swiften/EventLoop/EventLoop.h" namespace Swift { -FakeDNSSDQuerier::FakeDNSSDQuerier(const String& domain) : domain(domain) { +FakeDNSSDQuerier::FakeDNSSDQuerier(const String& domain, EventLoop* eventLoop) : domain(domain), eventLoop(eventLoop) { } FakeDNSSDQuerier::~FakeDNSSDQuerier() { @@ -46,24 +46,24 @@ void FakeDNSSDQuerier::addRunningQuery(boost::shared_ptr<FakeDNSSDQuery> query) allQueriesEverRun.push_back(query); if (boost::shared_ptr<FakeDNSSDBrowseQuery> browseQuery = boost::dynamic_pointer_cast<FakeDNSSDBrowseQuery>(query)) { foreach(const DNSSDServiceID& service, services) { - MainEventLoop::postEvent(boost::bind(boost::ref(browseQuery->onServiceAdded), service), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(browseQuery->onServiceAdded), service), shared_from_this()); } } else if (boost::shared_ptr<FakeDNSSDResolveServiceQuery> resolveQuery = boost::dynamic_pointer_cast<FakeDNSSDResolveServiceQuery>(query)) { for(ServiceInfoMap::const_iterator i = serviceInfo.begin(); i != serviceInfo.end(); ++i) { if (i->first == resolveQuery->service) { - MainEventLoop::postEvent(boost::bind(boost::ref(resolveQuery->onServiceResolved), i->second), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(resolveQuery->onServiceResolved), i->second), shared_from_this()); } } } else if (boost::shared_ptr<FakeDNSSDRegisterQuery> registerQuery = boost::dynamic_pointer_cast<FakeDNSSDRegisterQuery>(query)) { DNSSDServiceID service(registerQuery->name, domain); - MainEventLoop::postEvent(boost::bind(boost::ref(registerQuery->onRegisterFinished), service), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(registerQuery->onRegisterFinished), service), shared_from_this()); } else if (boost::shared_ptr<FakeDNSSDResolveHostnameQuery> resolveHostnameQuery = boost::dynamic_pointer_cast<FakeDNSSDResolveHostnameQuery>(query)) { std::map<String,boost::optional<HostAddress> >::const_iterator i = addresses.find(resolveHostnameQuery->hostname); if (i != addresses.end()) { - MainEventLoop::postEvent( + eventLoop->postEvent( boost::bind( boost::ref(resolveHostnameQuery->onHostnameResolved), i->second), shared_from_this()); @@ -79,7 +79,7 @@ void FakeDNSSDQuerier::removeRunningQuery(boost::shared_ptr<FakeDNSSDQuery> quer void FakeDNSSDQuerier::addService(const DNSSDServiceID& id) { services.insert(id); foreach(const boost::shared_ptr<FakeDNSSDBrowseQuery>& query, getQueries<FakeDNSSDBrowseQuery>()) { - MainEventLoop::postEvent(boost::bind(boost::ref(query->onServiceAdded), id), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(query->onServiceAdded), id), shared_from_this()); } } @@ -87,7 +87,7 @@ void FakeDNSSDQuerier::removeService(const DNSSDServiceID& id) { services.erase(id); serviceInfo.erase(id); foreach(const boost::shared_ptr<FakeDNSSDBrowseQuery>& query, getQueries<FakeDNSSDBrowseQuery>()) { - MainEventLoop::postEvent(boost::bind(boost::ref(query->onServiceRemoved), id), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(query->onServiceRemoved), id), shared_from_this()); } } @@ -98,7 +98,7 @@ void FakeDNSSDQuerier::setServiceInfo(const DNSSDServiceID& id, const DNSSDResol } foreach(const boost::shared_ptr<FakeDNSSDResolveServiceQuery>& query, getQueries<FakeDNSSDResolveServiceQuery>()) { if (query->service == id) { - MainEventLoop::postEvent(boost::bind(boost::ref(query->onServiceResolved), info), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(query->onServiceResolved), info), shared_from_this()); } } } @@ -114,13 +114,13 @@ bool FakeDNSSDQuerier::isServiceRegistered(const String& name, int port, const B void FakeDNSSDQuerier::setBrowseError() { foreach(const boost::shared_ptr<FakeDNSSDBrowseQuery>& query, getQueries<FakeDNSSDBrowseQuery>()) { - MainEventLoop::postEvent(boost::ref(query->onError), shared_from_this()); + eventLoop->postEvent(boost::ref(query->onError), shared_from_this()); } } void FakeDNSSDQuerier::setRegisterError() { foreach(const boost::shared_ptr<FakeDNSSDRegisterQuery>& query, getQueries<FakeDNSSDRegisterQuery>()) { - MainEventLoop::postEvent(boost::bind(boost::ref(query->onRegisterFinished), boost::optional<DNSSDServiceID>()), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(query->onRegisterFinished), boost::optional<DNSSDServiceID>()), shared_from_this()); } } @@ -128,7 +128,7 @@ void FakeDNSSDQuerier::setAddress(const String& hostname, boost::optional<HostAd addresses[hostname] = address; foreach(const boost::shared_ptr<FakeDNSSDResolveHostnameQuery>& query, getQueries<FakeDNSSDResolveHostnameQuery>()) { if (query->hostname == hostname) { - MainEventLoop::postEvent(boost::bind( + eventLoop->postEvent(boost::bind( boost::ref(query->onHostnameResolved), address), shared_from_this()); } } diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h index f08ab68..9338dd4 100644 --- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h +++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h @@ -22,13 +22,14 @@ namespace Swift { class ByteArray; class FakeDNSSDQuery; class FakeDNSSDBrowseQuery; + class EventLoop; class FakeDNSSDQuerier : public DNSSDQuerier, public EventOwner, public boost::enable_shared_from_this<FakeDNSSDQuerier> { public: - FakeDNSSDQuerier(const String& domain); + FakeDNSSDQuerier(const String& domain, EventLoop* eventLoop); ~FakeDNSSDQuerier(); void start() {} @@ -84,6 +85,7 @@ namespace Swift { private: String domain; + EventLoop* eventLoop; std::list< boost::shared_ptr<FakeDNSSDQuery> > runningQueries; std::list< boost::shared_ptr<FakeDNSSDQuery> > allQueriesEverRun; std::set<DNSSDServiceID> services; |