summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-07-18 10:17:45 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-07-18 11:54:02 (GMT)
commit7388443bda19877980e368a0654b55097db0bda7 (patch)
treec9ccbedfa94cecf4a6e2188e1cdb5420e3e97c3a /Swiften/LinkLocal/LinkLocalRoster.cpp
parent633c82407e47ec2ba7a92cef9c5b30a24a93fc68 (diff)
downloadswift-contrib-7388443bda19877980e368a0654b55097db0bda7.zip
swift-contrib-7388443bda19877980e368a0654b55097db0bda7.tar.bz2
Add DNS-SD hostname resolving.
Diffstat (limited to 'Swiften/LinkLocal/LinkLocalRoster.cpp')
-rw-r--r--Swiften/LinkLocal/LinkLocalRoster.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/Swiften/LinkLocal/LinkLocalRoster.cpp b/Swiften/LinkLocal/LinkLocalRoster.cpp
index fde52a9..feec7b7 100644
--- a/Swiften/LinkLocal/LinkLocalRoster.cpp
+++ b/Swiften/LinkLocal/LinkLocalRoster.cpp
@@ -2,15 +2,17 @@
#include <iostream>
#include "Swiften/LinkLocal/LinkLocalRoster.h"
+#include "Swiften/Network/HostAddress.h"
namespace Swift {
LinkLocalRoster::LinkLocalRoster(boost::shared_ptr<DNSSDService> service) : dnsSDService(service) {
+ dnsSDService->onStopped.connect(boost::bind(&LinkLocalRoster::handleStopped, this, _1));
+ dnsSDService->onServiceRegistered.connect(boost::bind(&LinkLocalRoster::handleServiceRegistered, this, _1));
dnsSDService->onServiceAdded.connect(boost::bind(&LinkLocalRoster::handleServiceAdded, this, _1));
dnsSDService->onServiceRemoved.connect(boost::bind(&LinkLocalRoster::handleServiceRemoved, this, _1));
dnsSDService->onServiceResolved.connect(boost::bind(&LinkLocalRoster::handleServiceResolved, this, _1, _2));
- dnsSDService->onError.connect(boost::bind(&LinkLocalRoster::handleDNSSDError, this));
- dnsSDService->onServiceRegistered.connect(boost::bind(&LinkLocalRoster::handleServiceRegistered, this, _1));
+ dnsSDService->onHostnameResolved.connect(boost::bind(&LinkLocalRoster::handleHostnameResolved, this, _1, _2));
}
void LinkLocalRoster::handleServiceAdded(const DNSSDService::Service& service) {
@@ -28,14 +30,25 @@ void LinkLocalRoster::handleServiceRemoved(const DNSSDService::Service& service)
void LinkLocalRoster::handleServiceResolved(const DNSSDService::Service& service, const DNSSDService::ResolveResult& result) {
std::cout << "Service resolved: " << service.name << "->" << result.host << " " << result.port << " " << result.info.getLastName() << std::endl;
+ dnsSDService->resolveHostname(result.host);
}
+void LinkLocalRoster::handleHostnameResolved(const String& hostname, const boost::optional<HostAddress>& address) {
+ if (address) {
+ std::cout << "Address resolved: " << hostname << " " << address->toString() << std::endl;
+ }
+ else {
+ std::cout << "Unable to resolve address for " << hostname << std::endl;
+ }
+}
+
+
void LinkLocalRoster::handleServiceRegistered(const DNSSDService::Service& service) {
selfService = service;
}
-void LinkLocalRoster::handleDNSSDError() {
- std::cout << "DNSSD Error" << std::endl;
+void LinkLocalRoster::handleStopped(bool error) {
+ std::cout << "DNSSDService stopped: " << error << std::endl;
}
}