summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-07-26 15:23:28 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-07-26 16:43:18 (GMT)
commit81ea0a6b0ea85c55c2f166b69da652aaab2ef79a (patch)
tree23ddd1388c3589bfd7d25650f4da3a1a4ab59723 /Swiften/LinkLocal/DNSSD/Fake
parente7ab68e8daf120d932d9eefc9053e9e064ca29af (diff)
downloadswift-contrib-81ea0a6b0ea85c55c2f166b69da652aaab2ef79a.zip
swift-contrib-81ea0a6b0ea85c55c2f166b69da652aaab2ef79a.tar.bz2
Test LinkLocal service registration.
Diffstat (limited to 'Swiften/LinkLocal/DNSSD/Fake')
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp15
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h4
2 files changed, 17 insertions, 2 deletions
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp
index 88c7774..5079192 100644
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp
+++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp
@@ -10,7 +10,7 @@
namespace Swift {
-FakeDNSSDQuerier::FakeDNSSDQuerier() {
+FakeDNSSDQuerier::FakeDNSSDQuerier(const String& domain) : domain(domain) {
}
boost::shared_ptr<DNSSDBrowseQuery> FakeDNSSDQuerier::createBrowseQuery() {
@@ -43,6 +43,10 @@ void FakeDNSSDQuerier::addRunningQuery(boost::shared_ptr<FakeDNSSDQuery> query)
}
}
}
+ else if (boost::shared_ptr<FakeDNSSDRegisterQuery> registerQuery = boost::dynamic_pointer_cast<FakeDNSSDRegisterQuery>(query)) {
+ DNSSDServiceID service(registerQuery->name, domain);
+ MainEventLoop::postEvent(boost::bind(boost::ref(registerQuery->onRegisterFinished), service), shared_from_this());
+ }
}
void FakeDNSSDQuerier::removeRunningQuery(boost::shared_ptr<FakeDNSSDQuery> query) {
@@ -77,6 +81,15 @@ void FakeDNSSDQuerier::setServiceInfo(const DNSSDServiceID& id, const DNSSDResol
}
}
+bool FakeDNSSDQuerier::isServiceRegistered(const String& name, int port, const ByteArray& info) {
+ foreach(const boost::shared_ptr<FakeDNSSDRegisterQuery>& query, getQueries<FakeDNSSDRegisterQuery>()) {
+ if (query->name == name && query->port == port && query->info == info) {
+ return true;
+ }
+ }
+ return false;
+}
+
void FakeDNSSDQuerier::setBrowseError() {
foreach(const boost::shared_ptr<FakeDNSSDBrowseQuery>& query, getQueries<FakeDNSSDBrowseQuery>()) {
MainEventLoop::postEvent(boost::ref(query->onError), shared_from_this());
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
index 43b717e..f2ec17b 100644
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
+++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
@@ -20,7 +20,7 @@ namespace Swift {
public EventOwner,
public boost::enable_shared_from_this<FakeDNSSDQuerier> {
public:
- FakeDNSSDQuerier();
+ FakeDNSSDQuerier(const String& domain);
boost::shared_ptr<DNSSDBrowseQuery> createBrowseQuery();
boost::shared_ptr<DNSSDRegisterQuery> createRegisterQuery(
@@ -36,6 +36,7 @@ namespace Swift {
void addService(const DNSSDServiceID& id);
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 setBrowseError();
void setRegisterError();
@@ -53,6 +54,7 @@ namespace Swift {
}
private:
+ String domain;
std::list< boost::shared_ptr<FakeDNSSDQuery> > runningQueries;
std::set<DNSSDServiceID> services;
typedef std::map<DNSSDServiceID,DNSSDResolveServiceQuery::Result> ServiceInfoMap;