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/Avahi | |
parent | a7da393cfc807048d320ddba8a1c7d24ef23a46e (diff) | |
download | swift-contrib-6810a2896f27e7ee07aee847f5e8dbccd1f6ec89.zip swift-contrib-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/Avahi')
4 files changed, 17 insertions, 17 deletions
diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiBrowseQuery.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiBrowseQuery.h index f8ec795..3bee907 100644 --- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiBrowseQuery.h +++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiBrowseQuery.h @@ -10,7 +10,7 @@ #include "Swiften/LinkLocal/DNSSD/Avahi/AvahiQuery.h" #include "Swiften/LinkLocal/DNSSD/DNSSDBrowseQuery.h" -#include "Swiften/EventLoop/MainEventLoop.h" +#include "Swiften/EventLoop/EventLoop.h" namespace Swift { class AvahiQuerier; @@ -27,7 +27,7 @@ namespace Swift { browser = avahi_service_browser_new(querier->getClient(), AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_presence._tcp", NULL, static_cast<AvahiLookupFlags>(0), &handleServiceDiscoveredStatic, this); if (!browser) { std::cout << "Error" << std::endl; - MainEventLoop::postEvent(boost::bind(boost::ref(onError)), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(onError)), shared_from_this()); } avahi_threaded_poll_unlock(querier->getThreadedPoll()); } @@ -49,18 +49,18 @@ namespace Swift { switch (event) { case AVAHI_BROWSER_FAILURE: std::cout << "Service browse error" << std::endl; - MainEventLoop::postEvent(boost::bind(boost::ref(onError)), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(onError)), shared_from_this()); break; case AVAHI_BROWSER_NEW: { DNSSDServiceID service(name, domain, type, interfaceIndex); std::cout << "Service discovered " << name << " " << domain << " " << type << " " << interfaceIndex << std::endl; - MainEventLoop::postEvent(boost::bind(boost::ref(onServiceAdded), service), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(onServiceAdded), service), shared_from_this()); break; } case AVAHI_BROWSER_REMOVE: { std::cout << "Service went away " << name << " " << domain << " " << type << " " << interfaceIndex << std::endl; DNSSDServiceID service(name, domain, type, interfaceIndex); - MainEventLoop::postEvent(boost::bind(boost::ref(onServiceRemoved), service), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(onServiceRemoved), service), shared_from_this()); break; } case AVAHI_BROWSER_ALL_FOR_NOW: diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h index 2045328..3e5a758 100644 --- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h +++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h @@ -11,7 +11,7 @@ #include "Swiften/LinkLocal/DNSSD/Avahi/AvahiQuery.h" #include "Swiften/LinkLocal/DNSSD/DNSSDRegisterQuery.h" #include "Swiften/Base/ByteArray.h" -#include "Swiften/EventLoop/MainEventLoop.h" +#include "Swiften/EventLoop/EventLoop.h" namespace Swift { class AvahiQuerier; @@ -29,7 +29,7 @@ namespace Swift { group = avahi_entry_group_new(querier->getClient(), handleEntryGroupChange, this); if (!group) { std::cout << "Error ceating entry group" << std::endl; - MainEventLoop::postEvent(boost::bind(boost::ref(onRegisterFinished), boost::optional<DNSSDServiceID>()), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(onRegisterFinished), boost::optional<DNSSDServiceID>()), shared_from_this()); } } @@ -61,7 +61,7 @@ namespace Swift { int result = avahi_entry_group_add_service_strlst(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, static_cast<AvahiPublishFlags>(0), name.getUTF8Data(), "_presence._tcp", NULL, NULL, port, txtList); if (result < 0) { std::cout << "Error registering service: " << avahi_strerror(result) << std::endl; - MainEventLoop::postEvent(boost::bind(boost::ref(onRegisterFinished), boost::optional<DNSSDServiceID>()), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(onRegisterFinished), boost::optional<DNSSDServiceID>()), shared_from_this()); } result = avahi_entry_group_commit(group); if (result < 0) { @@ -78,7 +78,7 @@ namespace Swift { switch (state) { case AVAHI_ENTRY_GROUP_ESTABLISHED : // Domain is a hack! - MainEventLoop::postEvent(boost::bind(boost::ref(onRegisterFinished), boost::optional<DNSSDServiceID>(DNSSDServiceID(name, "local", "_presence._tcp", 0))), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(onRegisterFinished), boost::optional<DNSSDServiceID>(DNSSDServiceID(name, "local", "_presence._tcp", 0))), shared_from_this()); std::cout << "Entry group established" << std::endl; break; case AVAHI_ENTRY_GROUP_COLLISION : { @@ -106,7 +106,7 @@ namespace Swift { if (result != kDNSServiceErr_NoError) { sdRef = NULL; }*/ - //MainEventLoop::postEvent(boost::bind(boost::ref(onRegisterFinished), boost::optional<DNSSDServiceID>()), shared_from_this()); + //eventLoop->postEvent(boost::bind(boost::ref(onRegisterFinished), boost::optional<DNSSDServiceID>()), shared_from_this()); } } @@ -117,7 +117,7 @@ namespace Swift { void handleServiceRegistered(DNSServiceErrorType errorCode, const char *name, const char *regtype, const char *domain) { if (errorCode != kDNSServiceErr_NoError) { - MainEventLoop::postEvent(boost::bind(boost::ref(onRegisterFinished), boost::optional<DNSSDServiceID>()), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(onRegisterFinished), boost::optional<DNSSDServiceID>()), shared_from_this()); } else { } diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveHostnameQuery.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveHostnameQuery.h index e069629..6803fd0 100644 --- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveHostnameQuery.h +++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveHostnameQuery.h @@ -9,7 +9,7 @@ #include "Swiften/Base/String.h" #include "Swiften/LinkLocal/DNSSD/Avahi/AvahiQuery.h" #include "Swiften/LinkLocal/DNSSD/DNSSDResolveHostnameQuery.h" -#include "Swiften/EventLoop/MainEventLoop.h" +#include "Swiften/EventLoop/EventLoop.h" #include "Swiften/Network/HostAddress.h" #include <netinet/in.h> @@ -24,7 +24,7 @@ namespace Swift { } void run() { - MainEventLoop::postEvent(boost::bind(boost::ref(onHostnameResolved), boost::optional<HostAddress>(HostAddress(hostname))), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(onHostnameResolved), boost::optional<HostAddress>(HostAddress(hostname))), shared_from_this()); } void finish() { diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveServiceQuery.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveServiceQuery.h index 4709677..402f84f 100644 --- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveServiceQuery.h +++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveServiceQuery.h @@ -10,7 +10,7 @@ #include "Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h" #include "Swiften/LinkLocal/LinkLocalServiceInfo.h" #include "Swiften/Base/ByteArray.h" -#include "Swiften/EventLoop/MainEventLoop.h" +#include "Swiften/EventLoop/EventLoop.h" namespace Swift { class AvahiQuerier; @@ -27,7 +27,7 @@ namespace Swift { resolver = avahi_service_resolver_new(querier->getClient(), service.getNetworkInterfaceID(), AVAHI_PROTO_UNSPEC, service.getName().getUTF8Data(), service.getType().getUTF8Data(), service.getDomain().getUTF8Data(), AVAHI_PROTO_UNSPEC, static_cast<AvahiLookupFlags>(0), handleServiceResolvedStatic, this); if (!resolver) { std::cout << "Error starting resolver" << std::endl; - MainEventLoop::postEvent(boost::bind(boost::ref(onServiceResolved), boost::optional<Result>()), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(onServiceResolved), boost::optional<Result>()), shared_from_this()); } avahi_threaded_poll_unlock(querier->getThreadedPoll()); } @@ -50,7 +50,7 @@ namespace Swift { switch(event) { case AVAHI_RESOLVER_FAILURE: std::cout << "Resolve error " << avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(resolver))) << std::endl; - MainEventLoop::postEvent(boost::bind(boost::ref(onServiceResolved), boost::optional<Result>()), shared_from_this()); + eventLoop->postEvent(boost::bind(boost::ref(onServiceResolved), boost::optional<Result>()), shared_from_this()); break; case AVAHI_RESOLVER_FOUND: { std::cout << "Success" << std::endl; @@ -64,7 +64,7 @@ namespace Swift { // FIXME: Probably not accurate String fullname = String(name) + "." + String(type) + "." + String(domain) + "."; std::cout << "Result: " << fullname << "->" << String(a) << ":" << port << std::endl; - MainEventLoop::postEvent( + eventLoop->postEvent( boost::bind( boost::ref(onServiceResolved), Result(fullname, String(a), port, txtRecord)), |