summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-07-31 21:26:33 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-08-01 09:13:35 (GMT)
commit336aa7d1c0a5aa223a6543d50ee17d82560c2b84 (patch)
treeb9b74a6502e011b85962173378464f96364c52d0 /Swiften/LinkLocal/DNSSD
parent67d69026c64a96b4e0dc64391b8bdcf43a187fab (diff)
downloadswift-336aa7d1c0a5aa223a6543d50ee17d82560c2b84.zip
swift-336aa7d1c0a5aa223a6543d50ee17d82560c2b84.tar.bz2
Added LinkLocalConnectorTest.
Diffstat (limited to 'Swiften/LinkLocal/DNSSD')
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp20
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h4
2 files changed, 24 insertions, 0 deletions
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp
index 5079192..0ba4dbb 100644
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp
+++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp
@@ -47,6 +47,22 @@ void FakeDNSSDQuerier::addRunningQuery(boost::shared_ptr<FakeDNSSDQuery> query)
DNSSDServiceID service(registerQuery->name, domain);
MainEventLoop::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,HostAddress>::const_iterator i = addresses.find(resolveHostnameQuery->hostname);
+ if (i != addresses.end()) {
+ MainEventLoop::postEvent(
+ boost::bind(
+ boost::ref(resolveHostnameQuery->onHostnameResolved), i->second),
+ shared_from_this());
+ }
+ else {
+ MainEventLoop::postEvent(
+ boost::bind(
+ boost::ref(resolveHostnameQuery->onHostnameResolved),
+ boost::optional<HostAddress>()),
+ shared_from_this());
+ }
+ }
}
void FakeDNSSDQuerier::removeRunningQuery(boost::shared_ptr<FakeDNSSDQuery> query) {
@@ -102,4 +118,8 @@ void FakeDNSSDQuerier::setRegisterError() {
}
}
+void FakeDNSSDQuerier::setAddress(const String& hostname, const HostAddress& address) {
+ addresses[hostname] = address;
+}
+
}
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
index f2ec17b..94d4074 100644
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
+++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
@@ -6,9 +6,11 @@
#include <set>
#include "Swiften/Base/foreach.h"
+#include "Swiften/Base/String.h"
#include "Swiften/EventLoop/EventOwner.h"
#include "Swiften/LinkLocal/DNSSD/DNSSDQuerier.h"
#include "Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h"
+#include "Swiften/Network/HostAddress.h"
namespace Swift {
class ByteArray;
@@ -37,6 +39,7 @@ namespace Swift {
void removeService(const DNSSDServiceID& id);
void setServiceInfo(const DNSSDServiceID& id, const DNSSDResolveServiceQuery::Result& info);
bool isServiceRegistered(const String& name, int port, const ByteArray& info);
+ void setAddress(const String& hostname, const HostAddress& address);
void setBrowseError();
void setRegisterError();
@@ -59,5 +62,6 @@ namespace Swift {
std::set<DNSSDServiceID> services;
typedef std::map<DNSSDServiceID,DNSSDResolveServiceQuery::Result> ServiceInfoMap;
ServiceInfoMap serviceInfo;
+ std::map<String, HostAddress> addresses;
};
}