summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-03-28 13:40:14 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-03-28 13:40:43 (GMT)
commitb61486fefe602e0d18fa5279021006f87b965307 (patch)
tree437585cbef1179e1ec31f79789591d5610200c29 /Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h
parentdae28dd45e43fc6e6ef2ec4c6c65d5d736ed86f8 (diff)
downloadswift-contrib-b61486fefe602e0d18fa5279021006f87b965307.zip
swift-contrib-b61486fefe602e0d18fa5279021006f87b965307.tar.bz2
Moved Swiften to a separate module.
Diffstat (limited to 'Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h')
m---------Swiften0
-rw-r--r--Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h63
2 files changed, 0 insertions, 63 deletions
diff --git a/Swiften b/Swiften
new file mode 160000
+Subproject 8213ba16d0043d2461f4b031c881d61dda5a38c
diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h
deleted file mode 100644
index 7b5f19a..0000000
--- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h
+++ /dev/null
@@ -1,63 +0,0 @@
-#pragma once
-
-#include "Swiften/Base/String.h"
-#include "Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuery.h"
-#include "Swiften/LinkLocal/DNSSD/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) {
- sdRef = NULL;
- }
- }
-
- //void DNSSDResolveHostnameQuery::run() {
- void run() {
- if (sdRef) {
- BonjourQuery::run();
- }
- else {
- MainEventLoop::postEvent(boost::bind(boost::ref(onHostnameResolved), boost::optional<HostAddress>()), shared_from_this());
- }
- }
-
- void finish() {
- BonjourQuery::finish();
- }
-
- 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());
- }
- }
- };
-}