summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-08-01 17:49:35 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-08-01 17:49:35 (GMT)
commit3a4c1c7a6fd03fed0bdfc3acc85d60ec1797361c (patch)
tree546b28d7970ef4b2bd719b04a3ec32530df8d680 /Swiften/LinkLocal/DNSSD/Fake
parentd856cc05a54eabe3014b8512b27192c9e8da35ff (diff)
downloadswift-3a4c1c7a6fd03fed0bdfc3acc85d60ec1797361c.zip
swift-3a4c1c7a6fd03fed0bdfc3acc85d60ec1797361c.tar.bz2
Added LinkLocalConnector::cancel().
Diffstat (limited to 'Swiften/LinkLocal/DNSSD/Fake')
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp17
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h4
2 files changed, 10 insertions, 11 deletions
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp
index 0ba4dbb..f7dfa11 100644
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp
+++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp
@@ -48,20 +48,13 @@ void FakeDNSSDQuerier::addRunningQuery(boost::shared_ptr<FakeDNSSDQuery> query)
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);
+ std::map<String,boost::optional<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());
- }
}
}
@@ -118,8 +111,14 @@ void FakeDNSSDQuerier::setRegisterError() {
}
}
-void FakeDNSSDQuerier::setAddress(const String& hostname, const HostAddress& address) {
+void FakeDNSSDQuerier::setAddress(const String& hostname, boost::optional<HostAddress> address) {
addresses[hostname] = address;
+ foreach(const boost::shared_ptr<FakeDNSSDResolveHostnameQuery>& query, getQueries<FakeDNSSDResolveHostnameQuery>()) {
+ if (query->hostname == hostname) {
+ MainEventLoop::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 94d4074..5af49dc 100644
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
+++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
@@ -39,7 +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 setAddress(const String& hostname, boost::optional<HostAddress> address);
void setBrowseError();
void setRegisterError();
@@ -62,6 +62,6 @@ namespace Swift {
std::set<DNSSDServiceID> services;
typedef std::map<DNSSDServiceID,DNSSDResolveServiceQuery::Result> ServiceInfoMap;
ServiceInfoMap serviceInfo;
- std::map<String, HostAddress> addresses;
+ std::map<String, boost::optional<HostAddress> > addresses;
};
}