summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-08-01 10:07:16 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-08-01 10:22:55 (GMT)
commit5a15e4df671aac30bba332801528a6283c2e4874 (patch)
tree8668089b7b9db89451b8b06ba7be29056a805f53 /Swiften
parent336aa7d1c0a5aa223a6543d50ee17d82560c2b84 (diff)
downloadswift-5a15e4df671aac30bba332801528a6283c2e4874.zip
swift-5a15e4df671aac30bba332801528a6283c2e4874.tar.bz2
Made Slimber fully functional again.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/LinkLocal/LinkLocalConnector.cpp16
-rw-r--r--Swiften/LinkLocal/LinkLocalConnector.h17
-rw-r--r--Swiften/LinkLocal/LinkLocalService.cpp4
-rw-r--r--Swiften/LinkLocal/LinkLocalService.h3
-rw-r--r--Swiften/LinkLocal/LinkLocalServiceBrowser.h5
-rw-r--r--Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp9
6 files changed, 30 insertions, 24 deletions
diff --git a/Swiften/LinkLocal/LinkLocalConnector.cpp b/Swiften/LinkLocal/LinkLocalConnector.cpp
index 13d57e8..40558d4 100644
--- a/Swiften/LinkLocal/LinkLocalConnector.cpp
+++ b/Swiften/LinkLocal/LinkLocalConnector.cpp
@@ -12,22 +12,18 @@
namespace Swift {
LinkLocalConnector::LinkLocalConnector(
- const JID& remoteJID,
- const String& hostname,
- int interfaceIndex,
- int port,
+ const LinkLocalService& service,
boost::shared_ptr<DNSSDQuerier> querier,
boost::shared_ptr<Connection> connection) :
- remoteJID(remoteJID),
- hostname(hostname),
- interfaceIndex(interfaceIndex),
- port(port),
+ service(service),
querier(querier),
connection(connection) {
}
void LinkLocalConnector::connect() {
- resolveQuery = querier->createResolveHostnameQuery(hostname, interfaceIndex);
+ resolveQuery = querier->createResolveHostnameQuery(
+ service.getHostname(),
+ service.getID().getNetworkInterfaceID());
resolveQuery->onHostnameResolved.connect(boost::bind(
&LinkLocalConnector::handleHostnameResolved,
boost::dynamic_pointer_cast<LinkLocalConnector>(shared_from_this()),
@@ -41,7 +37,7 @@ void LinkLocalConnector::handleHostnameResolved(const boost::optional<HostAddres
resolveQuery.reset();
connection->onConnectFinished.connect(
boost::bind(boost::ref(onConnectFinished), _1));
- connection->connect(HostAddressPort(*address, port));
+ connection->connect(HostAddressPort(*address, service.getPort()));
}
else {
onConnectFinished(true);
diff --git a/Swiften/LinkLocal/LinkLocalConnector.h b/Swiften/LinkLocal/LinkLocalConnector.h
index 134656c..fa293c4 100644
--- a/Swiften/LinkLocal/LinkLocalConnector.h
+++ b/Swiften/LinkLocal/LinkLocalConnector.h
@@ -5,13 +5,12 @@
#include <boost/enable_shared_from_this.hpp>
#include <vector>
-#include "Swiften/JID/JID.h"
#include "Swiften/Network/Connection.h"
+#include "Swiften/LinkLocal/LinkLocalService.h"
namespace Swift {
class ConnectionFactory;
class HostAddress;
- class String;
class Element;
class PayloadParserFactoryCollection;
class PayloadSerializerCollection;
@@ -21,15 +20,12 @@ namespace Swift {
class LinkLocalConnector : public boost::enable_shared_from_this<LinkLocalConnector> {
public:
LinkLocalConnector(
- const JID& remoteJID,
- const String& hostname,
- int interfaceIndex,
- int port,
+ const LinkLocalService& service,
boost::shared_ptr<DNSSDQuerier> querier,
boost::shared_ptr<Connection> connection);
- const JID& getRemoteJID() const {
- return remoteJID;
+ const LinkLocalService& getService() const {
+ return service;
}
void connect();
@@ -50,10 +46,7 @@ namespace Swift {
void handleConnected(bool error);
private:
- JID remoteJID;
- String hostname;
- int interfaceIndex;
- int port;
+ LinkLocalService service;
boost::shared_ptr<DNSSDQuerier> querier;
boost::shared_ptr<DNSSDResolveHostnameQuery> resolveQuery;
boost::shared_ptr<Connection> connection;
diff --git a/Swiften/LinkLocal/LinkLocalService.cpp b/Swiften/LinkLocal/LinkLocalService.cpp
index f567a63..f1114ed 100644
--- a/Swiften/LinkLocal/LinkLocalService.cpp
+++ b/Swiften/LinkLocal/LinkLocalService.cpp
@@ -20,4 +20,8 @@ String LinkLocalService::getDescription() const {
return getName();
}
+JID LinkLocalService::getJID() const {
+ return JID(getName());
+}
+
}
diff --git a/Swiften/LinkLocal/LinkLocalService.h b/Swiften/LinkLocal/LinkLocalService.h
index f7e9e3c..8ae593c 100644
--- a/Swiften/LinkLocal/LinkLocalService.h
+++ b/Swiften/LinkLocal/LinkLocalService.h
@@ -1,6 +1,7 @@
#pragma once
#include "Swiften/Base/String.h"
+#include "Swiften/JID/JID.h"
#include "Swiften/LinkLocal/DNSSD/DNSSDServiceID.h"
#include "Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h"
#include "Swiften/LinkLocal/LinkLocalServiceInfo.h"
@@ -36,6 +37,8 @@ namespace Swift {
String getDescription() const;
+ JID getJID() const;
+
private:
DNSSDServiceID id;
DNSSDResolveServiceQuery::Result info;
diff --git a/Swiften/LinkLocal/LinkLocalServiceBrowser.h b/Swiften/LinkLocal/LinkLocalServiceBrowser.h
index 7ef661c..66973d5 100644
--- a/Swiften/LinkLocal/LinkLocalServiceBrowser.h
+++ b/Swiften/LinkLocal/LinkLocalServiceBrowser.h
@@ -36,6 +36,11 @@ namespace Swift {
std::vector<LinkLocalService> getServices() const;
+ // FIXME: Ugly that we need this
+ boost::shared_ptr<DNSSDQuerier> getQuerier() const {
+ return querier;
+ }
+
boost::signal<void (const LinkLocalService&)> onServiceAdded;
boost::signal<void (const LinkLocalService&)> onServiceChanged;
boost::signal<void (const LinkLocalService&)> onServiceRemoved;
diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp
index 1b9b0aa..b052e6a 100644
--- a/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp
+++ b/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp
@@ -74,8 +74,13 @@ class LinkLocalConnectorTest : public CppUnit::TestFixture {
private:
boost::shared_ptr<LinkLocalConnector> createConnector(const String& hostname, int port) {
- boost::shared_ptr<LinkLocalConnector> result(new LinkLocalConnector(
- JID("rabbit@teaparty"), hostname, 0, port, querier, connection));
+ LinkLocalService service(
+ DNSSDServiceID("myname", "local."),
+ DNSSDResolveServiceQuery::Result(
+ "myname._presence._tcp.local", hostname, port,
+ LinkLocalServiceInfo().toTXTRecord()));
+ boost::shared_ptr<LinkLocalConnector> result(
+ new LinkLocalConnector(service, querier, connection));
result->onConnectFinished.connect(
boost::bind(&LinkLocalConnectorTest::handleConnected, this, _1));
return result;