diff options
author | Kevin Smith <git@kismith.co.uk> | 2009-07-31 18:38:11 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2009-07-31 18:38:11 (GMT) |
commit | 99b65c4dd72105755a7cf95297c9cf69dcbc6446 (patch) | |
tree | c6c862f6ef33b2260c44c0229b29f65351223e7c /Swiften/LinkLocal/LinkLocalConnector.cpp | |
parent | fed11bbc3bffd383e097ea63bb92442ce2daf6ed (diff) | |
parent | aa60aa80d2d170a536c246ef6c221f92de7dd8ed (diff) | |
download | swift-contrib-99b65c4dd72105755a7cf95297c9cf69dcbc6446.zip swift-contrib-99b65c4dd72105755a7cf95297c9cf69dcbc6446.tar.bz2 |
Merge commit 'origin/master' into roster
Diffstat (limited to 'Swiften/LinkLocal/LinkLocalConnector.cpp')
-rw-r--r-- | Swiften/LinkLocal/LinkLocalConnector.cpp | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/Swiften/LinkLocal/LinkLocalConnector.cpp b/Swiften/LinkLocal/LinkLocalConnector.cpp index af521b0..18b5d6a 100644 --- a/Swiften/LinkLocal/LinkLocalConnector.cpp +++ b/Swiften/LinkLocal/LinkLocalConnector.cpp @@ -6,42 +6,45 @@ #include "Swiften/Network/ConnectionFactory.h" #include "Swiften/Network/HostAddress.h" #include "Swiften/Network/HostAddressPort.h" -#include "Swiften/LinkLocal/DNSSDService.h" +#include "Swiften/LinkLocal/DNSSD/DNSSDQuerier.h" +#include "Swiften/LinkLocal/DNSSD/DNSSDResolveHostnameQuery.h" namespace Swift { LinkLocalConnector::LinkLocalConnector( const JID& remoteJID, const String& hostname, + int interfaceIndex, int port, - boost::shared_ptr<DNSSDService> resolver, + boost::shared_ptr<DNSSDQuerier> querier, boost::shared_ptr<Connection> connection) : - remoteJID_(remoteJID), - hostname_(hostname), - port_(port), - resolver_(resolver), - connection_(connection), - resolving_(false) { + remoteJID(remoteJID), + hostname(hostname), + interfaceIndex(interfaceIndex), + port(port), + querier(querier), + connection(connection) { } void LinkLocalConnector::connect() { - resolving_ = true; - resolver_->onHostnameResolved.connect(boost::bind(&LinkLocalConnector::handleHostnameResolved, boost::dynamic_pointer_cast<LinkLocalConnector>(shared_from_this()), _1, _2)); - resolver_->resolveHostname(hostname_); + resolveQuery = querier->createResolveHostnameQuery(hostname, interfaceIndex); + resolveQuery->onHostnameResolved.connect(boost::bind( + &LinkLocalConnector::handleHostnameResolved, + boost::dynamic_pointer_cast<LinkLocalConnector>(shared_from_this()), + _1)); + resolveQuery->run(); } -void LinkLocalConnector::handleHostnameResolved(const String& hostname, const boost::optional<HostAddress>& address) { - if (resolving_) { - if (hostname == hostname_) { - resolving_ = false; - if (address) { - connection_->onConnectFinished.connect(boost::bind(boost::ref(onConnectFinished), _1)); - connection_->connect(HostAddressPort(*address, port_)); - } - else { - onConnectFinished(false); - } - } +void LinkLocalConnector::handleHostnameResolved(const boost::optional<HostAddress>& address) { + if (address) { + resolveQuery->finish(); + resolveQuery.reset(); + connection->onConnectFinished.connect( + boost::bind(boost::ref(onConnectFinished), _1)); + connection->connect(HostAddressPort(*address, port)); + } + else { + onConnectFinished(false); } } @@ -50,7 +53,7 @@ void LinkLocalConnector::handleConnected(bool error) { } void LinkLocalConnector::queueElement(boost::shared_ptr<Element> element) { - queuedElements_.push_back(element); + queuedElements.push_back(element); } |