diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-07-25 09:37:42 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-07-25 09:37:42 (GMT) |
commit | 0f77a684b42f25052eb1cfa688721e321526a90d (patch) | |
tree | 226c07deff7a663f8aefdfc8814e9ecd04085999 /Swiften/LinkLocal/BonjourResolveHostnameQuery.h | |
parent | b33a2937fe4a3cae0017892ad7f5c27b8a6f976d (diff) | |
download | swift-contrib-0f77a684b42f25052eb1cfa688721e321526a90d.zip swift-contrib-0f77a684b42f25052eb1cfa688721e321526a90d.tar.bz2 |
Created DNSSD submodule for LinkLocal.
Diffstat (limited to 'Swiften/LinkLocal/BonjourResolveHostnameQuery.h')
-rw-r--r-- | Swiften/LinkLocal/BonjourResolveHostnameQuery.h | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/Swiften/LinkLocal/BonjourResolveHostnameQuery.h b/Swiften/LinkLocal/BonjourResolveHostnameQuery.h deleted file mode 100644 index 771fc84..0000000 --- a/Swiften/LinkLocal/BonjourResolveHostnameQuery.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#include "Swiften/Base/String.h" -#include "Swiften/LinkLocal/BonjourQuery.h" -#include "Swiften/LinkLocal/DNSSDResolveHostnameQuery.h" -#include "Swiften/EventLoop/MainEventLoop.h" -#include "Swiften/Network/HostAddress.h" - -#include <netinet/in.h> - -namespace Swift { - class BonjourQuerier; - - class BonjourResolveHostnameQuery : public DNSSDResolveHostnameQuery, public BonjourQuery { - public: - BonjourResolveHostnameQuery(const String& hostname, int interfaceIndex, boost::shared_ptr<BonjourQuerier> querier) : BonjourQuery(querier) { - DNSServiceErrorType result = DNSServiceGetAddrInfo( - &sdRef, 0, interfaceIndex, kDNSServiceProtocol_IPv4, - hostname.getUTF8Data(), - &BonjourResolveHostnameQuery::handleHostnameResolvedStatic, this); - if (result != kDNSServiceErr_NoError) { - MainEventLoop::postEvent(boost::bind(boost::ref(onHostnameResolved), boost::optional<HostAddress>()), shared_from_this()); - } - } - - //void DNSSDResolveHostnameQuery::run() { - void run() { - BonjourQuery::run(); - } - - private: - static void handleHostnameResolvedStatic(DNSServiceRef, DNSServiceFlags, uint32_t, DNSServiceErrorType errorCode, const char*, const struct sockaddr *address, uint32_t, void *context) { - static_cast<BonjourResolveHostnameQuery*>(context)->handleHostnameResolved(errorCode, address); - } - - void handleHostnameResolved(DNSServiceErrorType errorCode, const struct sockaddr *rawAddress) { - if (errorCode) { - MainEventLoop::postEvent( - boost::bind(boost::ref(onHostnameResolved), - boost::optional<HostAddress>()), - shared_from_this()); - } - else { - assert(rawAddress->sa_family == AF_INET); - const sockaddr_in* sa = reinterpret_cast<const sockaddr_in*>(rawAddress); - uint32_t address = ntohl(sa->sin_addr.s_addr); - MainEventLoop::postEvent(boost::bind( - boost::ref(onHostnameResolved), - HostAddress(reinterpret_cast<unsigned char*>(&address), 4)), - shared_from_this()); - } - } - }; -} |