summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/LinkLocal/DNSSD/Fake')
m---------Swiften0
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDBrowseQuery.h22
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp130
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h71
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuery.cpp20
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuery.h25
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h32
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveHostnameQuery.h27
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveServiceQuery.h25
9 files changed, 0 insertions, 352 deletions
diff --git a/Swiften b/Swiften
new file mode 160000
+Subproject 8213ba16d0043d2461f4b031c881d61dda5a38c
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDBrowseQuery.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDBrowseQuery.h
deleted file mode 100644
index 5a0b93b..0000000
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDBrowseQuery.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#pragma once
-
-#include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuery.h"
-#include "Swiften/LinkLocal/DNSSD/DNSSDBrowseQuery.h"
-
-namespace Swift {
- class FakeDNSSDQuerier;
-
- class FakeDNSSDBrowseQuery : public DNSSDBrowseQuery, public FakeDNSSDQuery {
- public:
- FakeDNSSDBrowseQuery(boost::shared_ptr<FakeDNSSDQuerier> querier) : FakeDNSSDQuery(querier) {
- }
-
- void startBrowsing() {
- run();
- }
-
- void stopBrowsing() {
- finish();
- }
- };
-}
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp
deleted file mode 100644
index c26f8ee..0000000
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-#include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h"
-
-#include <boost/bind.hpp>
-
-#include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDBrowseQuery.h"
-#include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h"
-#include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveServiceQuery.h"
-#include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveHostnameQuery.h"
-#include "Swiften/EventLoop/MainEventLoop.h"
-
-namespace Swift {
-
-FakeDNSSDQuerier::FakeDNSSDQuerier(const String& domain) : domain(domain) {
-}
-
-FakeDNSSDQuerier::~FakeDNSSDQuerier() {
- if (!runningQueries.empty()) {
- std::cerr << "FakeDNSSDQuerier: Running queries not empty at destruction time" << std::endl;
- }
-}
-
-boost::shared_ptr<DNSSDBrowseQuery> FakeDNSSDQuerier::createBrowseQuery() {
- return boost::shared_ptr<DNSSDBrowseQuery>(new FakeDNSSDBrowseQuery(shared_from_this()));
-}
-
-boost::shared_ptr<DNSSDRegisterQuery> FakeDNSSDQuerier::createRegisterQuery(const String& name, int port, const ByteArray& info) {
- return boost::shared_ptr<DNSSDRegisterQuery>(new FakeDNSSDRegisterQuery(name, port, info, shared_from_this()));
-}
-
-boost::shared_ptr<DNSSDResolveServiceQuery> FakeDNSSDQuerier::createResolveServiceQuery(const DNSSDServiceID& service) {
- return boost::shared_ptr<DNSSDResolveServiceQuery>(new FakeDNSSDResolveServiceQuery(service, shared_from_this()));
-}
-
-boost::shared_ptr<DNSSDResolveHostnameQuery> FakeDNSSDQuerier::createResolveHostnameQuery(const String& hostname, int interfaceIndex) {
- return boost::shared_ptr<DNSSDResolveHostnameQuery>(new FakeDNSSDResolveHostnameQuery(hostname, interfaceIndex, shared_from_this()));
-}
-
-void FakeDNSSDQuerier::addRunningQuery(boost::shared_ptr<FakeDNSSDQuery> query) {
- runningQueries.push_back(query);
- if (boost::shared_ptr<FakeDNSSDBrowseQuery> browseQuery = boost::dynamic_pointer_cast<FakeDNSSDBrowseQuery>(query)) {
- foreach(const DNSSDServiceID& service, services) {
- MainEventLoop::postEvent(boost::bind(boost::ref(browseQuery->onServiceAdded), service), shared_from_this());
- }
- }
- else if (boost::shared_ptr<FakeDNSSDResolveServiceQuery> resolveQuery = boost::dynamic_pointer_cast<FakeDNSSDResolveServiceQuery>(query)) {
- for(ServiceInfoMap::const_iterator i = serviceInfo.begin(); i != serviceInfo.end(); ++i) {
- if (i->first == resolveQuery->service) {
- MainEventLoop::postEvent(boost::bind(boost::ref(resolveQuery->onServiceResolved), i->second), shared_from_this());
- }
- }
- }
- 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());
- }
- else if (boost::shared_ptr<FakeDNSSDResolveHostnameQuery> resolveHostnameQuery = boost::dynamic_pointer_cast<FakeDNSSDResolveHostnameQuery>(query)) {
- 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());
- }
- }
-}
-
-void FakeDNSSDQuerier::removeRunningQuery(boost::shared_ptr<FakeDNSSDQuery> query) {
- runningQueries.erase(std::remove(
- runningQueries.begin(), runningQueries.end(), query), runningQueries.end());
-}
-
-void FakeDNSSDQuerier::addService(const DNSSDServiceID& id) {
- services.insert(id);
- foreach(const boost::shared_ptr<FakeDNSSDBrowseQuery>& query, getQueries<FakeDNSSDBrowseQuery>()) {
- MainEventLoop::postEvent(boost::bind(boost::ref(query->onServiceAdded), id), shared_from_this());
- }
-}
-
-void FakeDNSSDQuerier::removeService(const DNSSDServiceID& id) {
- services.erase(id);
- serviceInfo.erase(id);
- foreach(const boost::shared_ptr<FakeDNSSDBrowseQuery>& query, getQueries<FakeDNSSDBrowseQuery>()) {
- MainEventLoop::postEvent(boost::bind(boost::ref(query->onServiceRemoved), id), shared_from_this());
- }
-}
-
-void FakeDNSSDQuerier::setServiceInfo(const DNSSDServiceID& id, const DNSSDResolveServiceQuery::Result& info) {
- std::pair<ServiceInfoMap::iterator, bool> r = serviceInfo.insert(std::make_pair(id, info));
- if (!r.second) {
- r.first->second = info;
- }
- foreach(const boost::shared_ptr<FakeDNSSDResolveServiceQuery>& query, getQueries<FakeDNSSDResolveServiceQuery>()) {
- if (query->service == id) {
- MainEventLoop::postEvent(boost::bind(boost::ref(query->onServiceResolved), info), shared_from_this());
- }
- }
-}
-
-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());
- }
-}
-
-void FakeDNSSDQuerier::setRegisterError() {
- foreach(const boost::shared_ptr<FakeDNSSDRegisterQuery>& query, getQueries<FakeDNSSDRegisterQuery>()) {
- MainEventLoop::postEvent(boost::bind(boost::ref(query->onRegisterFinished), boost::optional<DNSSDServiceID>()), shared_from_this());
- }
-}
-
-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
deleted file mode 100644
index 22bca0c..0000000
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
+++ /dev/null
@@ -1,71 +0,0 @@
-#pragma once
-
-#include <boost/shared_ptr.hpp>
-#include <boost/enable_shared_from_this.hpp>
-#include <list>
-#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;
- class FakeDNSSDQuery;
- class FakeDNSSDBrowseQuery;
-
- class FakeDNSSDQuerier :
- public DNSSDQuerier,
- public EventOwner,
- public boost::enable_shared_from_this<FakeDNSSDQuerier> {
- public:
- FakeDNSSDQuerier(const String& domain);
- ~FakeDNSSDQuerier();
-
- void start() {}
- void stop() {}
-
- boost::shared_ptr<DNSSDBrowseQuery> createBrowseQuery();
- boost::shared_ptr<DNSSDRegisterQuery> createRegisterQuery(
- const String& name, int port, const ByteArray& info);
- boost::shared_ptr<DNSSDResolveServiceQuery> createResolveServiceQuery(
- const DNSSDServiceID&);
- boost::shared_ptr<DNSSDResolveHostnameQuery> createResolveHostnameQuery(
- const String& hostname, int interfaceIndex);
-
- void addRunningQuery(boost::shared_ptr<FakeDNSSDQuery>);
- void removeRunningQuery(boost::shared_ptr<FakeDNSSDQuery>);
-
- 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 setAddress(const String& hostname, boost::optional<HostAddress> address);
-
- void setBrowseError();
- void setRegisterError();
-
- private:
- template<typename T>
- std::vector< boost::shared_ptr<T> > getQueries() const {
- std::vector< boost::shared_ptr<T> > result;
- foreach(const boost::shared_ptr<FakeDNSSDQuery>& query, runningQueries) {
- if (boost::shared_ptr<T> resultQuery = boost::dynamic_pointer_cast<T>(query)) {
- result.push_back(resultQuery);
- }
- }
- return result;
- }
-
- private:
- String domain;
- std::list< boost::shared_ptr<FakeDNSSDQuery> > runningQueries;
- std::set<DNSSDServiceID> services;
- typedef std::map<DNSSDServiceID,DNSSDResolveServiceQuery::Result> ServiceInfoMap;
- ServiceInfoMap serviceInfo;
- std::map<String, boost::optional<HostAddress> > addresses;
- };
-}
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuery.cpp b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuery.cpp
deleted file mode 100644
index ced7850..0000000
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuery.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuery.h"
-#include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h"
-
-namespace Swift {
-
-FakeDNSSDQuery::FakeDNSSDQuery(boost::shared_ptr<FakeDNSSDQuerier> querier) : querier(querier) {
-}
-
-FakeDNSSDQuery::~FakeDNSSDQuery() {
-}
-
-void FakeDNSSDQuery::run() {
- querier->addRunningQuery(shared_from_this());
-}
-
-void FakeDNSSDQuery::finish() {
- querier->removeRunningQuery(shared_from_this());
-}
-
-}
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuery.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuery.h
deleted file mode 100644
index 9fca1d4..0000000
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuery.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma once
-
-#include <boost/shared_ptr.hpp>
-#include <boost/enable_shared_from_this.hpp>
-
-#include "Swiften/EventLoop/EventOwner.h"
-
-namespace Swift {
- class FakeDNSSDQuerier;
-
- class FakeDNSSDQuery :
- public EventOwner,
- public boost::enable_shared_from_this<FakeDNSSDQuery> {
- public:
- FakeDNSSDQuery(boost::shared_ptr<FakeDNSSDQuerier>);
- virtual ~FakeDNSSDQuery();
-
- protected:
- void run();
- void finish();
-
- protected:
- boost::shared_ptr<FakeDNSSDQuerier> querier;
- };
-}
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h
deleted file mode 100644
index 82ec623..0000000
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#pragma once
-
-#include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuery.h"
-#include "Swiften/LinkLocal/DNSSD/DNSSDRegisterQuery.h"
-#include "Swiften/Base/ByteArray.h"
-#include "Swiften/Base/String.h"
-
-namespace Swift {
- class FakeDNSSDQuerier;
-
- class FakeDNSSDRegisterQuery : public DNSSDRegisterQuery, public FakeDNSSDQuery {
- public:
- FakeDNSSDRegisterQuery(const String& name, int port, const ByteArray& info, boost::shared_ptr<FakeDNSSDQuerier> querier) : FakeDNSSDQuery(querier), name(name), port(port), info(info) {
- }
-
- void registerService() {
- run();
- }
-
- void updateServiceInfo(const ByteArray& i) {
- info = i;
- }
-
- void unregisterService() {
- finish();
- }
-
- String name;
- int port;
- ByteArray info;
- };
-}
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveHostnameQuery.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveHostnameQuery.h
deleted file mode 100644
index 5ed42af..0000000
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveHostnameQuery.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#pragma once
-
-#include "Swiften/Base/String.h"
-#include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuery.h"
-#include "Swiften/LinkLocal/DNSSD/DNSSDResolveHostnameQuery.h"
-#include "Swiften/Network/HostAddress.h"
-
-namespace Swift {
- class FakeDNSSDQuerier;
-
- class FakeDNSSDResolveHostnameQuery : public DNSSDResolveHostnameQuery, public FakeDNSSDQuery {
- public:
- FakeDNSSDResolveHostnameQuery(const String& hostname, int interfaceIndex, boost::shared_ptr<FakeDNSSDQuerier> querier) : FakeDNSSDQuery(querier), hostname(hostname), interfaceIndex(interfaceIndex) {
- }
-
- void run() {
- FakeDNSSDQuery::run();
- }
-
- void finish() {
- FakeDNSSDQuery::finish();
- }
-
- String hostname;
- int interfaceIndex;
- };
-}
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveServiceQuery.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveServiceQuery.h
deleted file mode 100644
index 60d35e5..0000000
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveServiceQuery.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma once
-
-#include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuery.h"
-#include "Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h"
-#include "Swiften/LinkLocal/LinkLocalServiceInfo.h"
-
-namespace Swift {
- class FakeDNSSDQuerier;
-
- class FakeDNSSDResolveServiceQuery : public DNSSDResolveServiceQuery, public FakeDNSSDQuery {
- public:
- FakeDNSSDResolveServiceQuery(const DNSSDServiceID& service, boost::shared_ptr<FakeDNSSDQuerier> querier) : FakeDNSSDQuery(querier), service(service) {
- }
-
- void start() {
- run();
- }
-
- void stop() {
- finish();
- }
-
- DNSSDServiceID service;
- };
-}