summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-07-29 20:18:02 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-07-30 18:31:58 (GMT)
commitb145bde2b103b0e688eef6300d34668431c5ad04 (patch)
tree4789bd165ed919e20f80bbfb658263302c8a71c7 /Swiften/LinkLocal
parent4b809245dd6a1236dda99ab780485599434a419a (diff)
downloadswift-b145bde2b103b0e688eef6300d34668431c5ad04.zip
swift-b145bde2b103b0e688eef6300d34668431c5ad04.tar.bz2
Created LinkLocalPresenceManager.
Diffstat (limited to 'Swiften/LinkLocal')
-rw-r--r--Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h1
-rw-r--r--Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h1
-rw-r--r--Swiften/LinkLocal/LinkLocalServiceBrowser.cpp11
-rw-r--r--Swiften/LinkLocal/LinkLocalServiceBrowser.h6
-rw-r--r--Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp20
5 files changed, 22 insertions, 17 deletions
diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h
index be0c921..c605175 100644
--- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourBrowseQuery.h
@@ -41,6 +41,7 @@ namespace Swift {
MainEventLoop::postEvent(boost::bind(boost::ref(onError)), shared_from_this());
}
else {
+ std::cout << "Discovered service: name:" << name << " domain:" << domain << " type: " << type << std::endl;
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/Bonjour/BonjourResolveServiceQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h
index d16ca5b..886b87b 100644
--- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h
@@ -45,6 +45,7 @@ namespace Swift {
MainEventLoop::postEvent(boost::bind(boost::ref(onServiceResolved), boost::optional<Result>()), shared_from_this());
}
else {
+ std::cout << "Service resolved: name:" << fullName << " host:" << host << " port:" << port << std::endl;
MainEventLoop::postEvent(
boost::bind(
boost::ref(onServiceResolved),
diff --git a/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp b/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp
index f7c5478..f65cd7a 100644
--- a/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp
+++ b/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp
@@ -102,19 +102,22 @@ void LinkLocalServiceBrowser::handleServiceRemoved(const DNSSDServiceID& service
assert(i != resolveQueries.end());
i->second->stop();
resolveQueries.erase(i);
- services.erase(service);
- onServiceRemoved(service);
+ ServiceMap::iterator j = services.find(service);
+ assert(j != services.end());
+ LinkLocalService linkLocalService(j->first, j->second);
+ services.erase(j);
+ onServiceRemoved(linkLocalService);
}
void LinkLocalServiceBrowser::handleServiceResolved(const DNSSDServiceID& service, const boost::optional<DNSSDResolveServiceQuery::Result>& result) {
if (result) {
std::pair<ServiceMap::iterator, bool> r = services.insert(std::make_pair(service, *result));
if (r.second) {
- onServiceAdded(service);
+ onServiceAdded(LinkLocalService(r.first->first, r.first->second));
}
else {
r.first->second = *result;
- onServiceChanged(service);
+ onServiceChanged(LinkLocalService(r.first->first, r.first->second));
}
}
}
diff --git a/Swiften/LinkLocal/LinkLocalServiceBrowser.h b/Swiften/LinkLocal/LinkLocalServiceBrowser.h
index dcdd576..a6623b1 100644
--- a/Swiften/LinkLocal/LinkLocalServiceBrowser.h
+++ b/Swiften/LinkLocal/LinkLocalServiceBrowser.h
@@ -31,9 +31,9 @@ namespace Swift {
std::vector<LinkLocalService> getServices() const;
- boost::signal<void (const DNSSDServiceID&)> onServiceAdded;
- boost::signal<void (const DNSSDServiceID&)> onServiceChanged;
- boost::signal<void (const DNSSDServiceID&)> onServiceRemoved;
+ boost::signal<void (const LinkLocalService&)> onServiceAdded;
+ boost::signal<void (const LinkLocalService&)> onServiceChanged;
+ boost::signal<void (const LinkLocalService&)> onServiceRemoved;
boost::signal<void (bool)> onStopped;
private:
diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp
index e9501cb..6e4d3b4 100644
--- a/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp
+++ b/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp
@@ -84,7 +84,7 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture {
eventLoop->processEvents();
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(addedServices.size()));
- CPPUNIT_ASSERT(addedServices[0] == *testServiceID);
+ CPPUNIT_ASSERT(addedServices[0].getID() == *testServiceID);
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(changedServices.size()));
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(removedServices.size()));
std::vector<LinkLocalService> services = testling->getServices();
@@ -141,7 +141,7 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture {
eventLoop->processEvents();
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(addedServices.size()));
- CPPUNIT_ASSERT(addedServices[0] == *aliceServiceID);
+ CPPUNIT_ASSERT(addedServices[0].getID() == *aliceServiceID);
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(changedServices.size()));
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(removedServices.size()));
std::vector<LinkLocalService> services = testling->getServices();
@@ -166,7 +166,7 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(addedServices.size()));
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changedServices.size()));
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(removedServices.size()));
- CPPUNIT_ASSERT(changedServices[0] == *testServiceID);
+ CPPUNIT_ASSERT(changedServices[0].getID() == *testServiceID);
std::vector<LinkLocalService> services = testling->getServices();
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(services.size()));
CPPUNIT_ASSERT(*testServiceID == services[0].getID());
@@ -191,7 +191,7 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(addedServices.size()));
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(changedServices.size()));
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(removedServices.size()));
- CPPUNIT_ASSERT(removedServices[0] == *testServiceID);
+ CPPUNIT_ASSERT(removedServices[0].getID() == *testServiceID);
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(testling->getServices().size()));
testling->stop();
@@ -294,15 +294,15 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture {
return testling;
}
- void handleServiceAdded(const DNSSDServiceID& service) {
+ void handleServiceAdded(const LinkLocalService& service) {
addedServices.push_back(service);
}
- void handleServiceRemoved(const DNSSDServiceID& service) {
+ void handleServiceRemoved(const LinkLocalService& service) {
removedServices.push_back(service);
}
- void handleServiceChanged(const DNSSDServiceID& service) {
+ void handleServiceChanged(const LinkLocalService& service) {
changedServices.push_back(service);
}
@@ -320,9 +320,9 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture {
private:
DummyEventLoop* eventLoop;
boost::shared_ptr<FakeDNSSDQuerier> querier;
- std::vector<DNSSDServiceID> addedServices;
- std::vector<DNSSDServiceID> changedServices;
- std::vector<DNSSDServiceID> removedServices;
+ std::vector<LinkLocalService> addedServices;
+ std::vector<LinkLocalService> changedServices;
+ std::vector<LinkLocalService> removedServices;
DNSSDServiceID* aliceServiceID;
DNSSDResolveServiceQuery::Result* aliceServiceInfo;
DNSSDServiceID* testServiceID;