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
parente7ab68e8daf120d932d9eefc9053e9e064ca29af (diff)
downloadswift-contrib-81ea0a6b0ea85c55c2f166b69da652aaab2ef79a.zip
swift-contrib-81ea0a6b0ea85c55c2f166b69da652aaab2ef79a.tar.bz2
Test LinkLocal service registration.
Diffstat (limited to 'Swiften/LinkLocal/DNSSD')
-rw-r--r--Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h2
-rw-r--r--Swiften/LinkLocal/DNSSD/DNSSDServiceID.h26
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp15
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h4
4 files changed, 31 insertions, 16 deletions
diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h
index 8e3181e..be0c921 100644
--- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h
@@ -41,7 +41,7 @@ namespace Swift {
MainEventLoop::postEvent(boost::bind(boost::ref(onError)), shared_from_this());
}
else {
- DNSSDServiceID service(name, type, domain, interfaceIndex);
+ DNSSDServiceID service(name, domain, type, interfaceIndex);
if (flags & kDNSServiceFlagsAdd) {
MainEventLoop::postEvent(boost::bind(boost::ref(onServiceAdded), service), shared_from_this());
}
diff --git a/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h b/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h
index b1986d3..5243662 100644
--- a/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h
+++ b/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h
@@ -9,31 +9,31 @@ namespace Swift {
DNSSDServiceID(
const String& name,
- const String& type,
- const String& domain = PresenceServiceType,
+ const String& domain,
+ const String& type = PresenceServiceType,
int networkInterface = 0) :
name(name),
- type(type),
domain(domain),
+ type(type),
networkInterface(networkInterface) {
}
bool operator==(const DNSSDServiceID& o) const {
- return name == o.name && type == o.type && domain == o.domain && (networkInterface != 0 && o.networkInterface != 0 ? networkInterface == o.networkInterface : true);
+ return name == o.name && domain == o.domain && type == o.type && (networkInterface != 0 && o.networkInterface != 0 ? networkInterface == o.networkInterface : true);
}
bool operator<(const DNSSDServiceID& o) const {
if (o.name == name) {
- if (o.type == type) {
- if (o.domain == domain) {
+ if (o.domain == domain) {
+ if (o.type == type) {
return networkInterface < o.networkInterface;
}
else {
- return domain < o.domain;
+ return type < o.type;
}
}
else {
- return type < o.type;
+ return domain < o.domain;
}
}
else {
@@ -45,22 +45,22 @@ namespace Swift {
return name;
}
- const String& getType() const {
- return type;
- }
-
const String& getDomain() const {
return domain;
}
+ const String& getType() const {
+ return type;
+ }
+
int getNetworkInterfaceID() const {
return networkInterface;
}
private:
String name;
- String type;
String domain;
+ String type;
int networkInterface;
};
}
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;