summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-09-30 20:58:49 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-09-30 21:04:33 (GMT)
commita1b590f2e469191381b5eb8613b5618ffbcafcc4 (patch)
tree3aa0843c76524d817f0713d6d061cdc380c13a59
parentd0081aeea512cc367a1aa9939693d8247b0571af (diff)
downloadswift-contrib-a1b590f2e469191381b5eb8613b5618ffbcafcc4.zip
swift-contrib-a1b590f2e469191381b5eb8613b5618ffbcafcc4.tar.bz2
Moved DiscoServiceWalker to Swiften.
-rw-r--r--Swift/Controllers/Chat/MUCSearchController.cpp2
-rw-r--r--Swift/Controllers/Chat/UserSearchController.cpp2
-rw-r--r--Swift/Controllers/FileTransfer/SOCKS5BytestreamProxyFinder.h2
-rw-r--r--Swift/Controllers/SConscript1
-rw-r--r--Swiften/Disco/DiscoServiceWalker.cpp (renamed from Swift/Controllers/DiscoServiceWalker.cpp)37
-rw-r--r--Swiften/Disco/DiscoServiceWalker.h (renamed from Swift/Controllers/DiscoServiceWalker.h)1
-rw-r--r--Swiften/Disco/SConscript1
7 files changed, 11 insertions, 35 deletions
diff --git a/Swift/Controllers/Chat/MUCSearchController.cpp b/Swift/Controllers/Chat/MUCSearchController.cpp
index 2cb89b4..5312fa7 100644
--- a/Swift/Controllers/Chat/MUCSearchController.cpp
+++ b/Swift/Controllers/Chat/MUCSearchController.cpp
@@ -11,19 +11,19 @@
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include <Swiften/Base/foreach.h>
#include <Swiften/Disco/GetDiscoItemsRequest.h>
#include <Swiften/Base/Log.h>
#include <Swiften/Base/String.h>
#include <Swift/Controllers/UIEvents/UIEventStream.h>
#include <Swift/Controllers/UIInterfaces/MUCSearchWindowFactory.h>
-#include <Swift/Controllers/DiscoServiceWalker.h>
+#include <Swiften/Disco/DiscoServiceWalker.h>
#include <Swiften/Client/NickResolver.h>
namespace Swift {
static const std::string SEARCHED_SERVICES = "searchedServices";
MUCSearchController::MUCSearchController(const JID& jid, MUCSearchWindowFactory* factory, IQRouter* iqRouter, ProfileSettingsProvider* settings) : jid_(jid), factory_(factory), iqRouter_(iqRouter), settings_(settings), window_(NULL), walker_(NULL) {
itemsInProgress_ = 0;
loadSavedServices();
diff --git a/Swift/Controllers/Chat/UserSearchController.cpp b/Swift/Controllers/Chat/UserSearchController.cpp
index 5a76c5d..3e734df 100644
--- a/Swift/Controllers/Chat/UserSearchController.cpp
+++ b/Swift/Controllers/Chat/UserSearchController.cpp
@@ -6,19 +6,19 @@
#include <Swift/Controllers/Chat/UserSearchController.h>
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include <Swiften/Base/foreach.h>
#include <Swiften/Disco/GetDiscoInfoRequest.h>
#include <Swiften/Disco/GetDiscoItemsRequest.h>
-#include <Swift/Controllers/DiscoServiceWalker.h>
+#include <Swiften/Disco/DiscoServiceWalker.h>
#include <Swift/Controllers/UIEvents/UIEventStream.h>
#include <Swift/Controllers/UIEvents/RequestChatWithUserDialogUIEvent.h>
#include <Swift/Controllers/UIEvents/RequestAddUserDialogUIEvent.h>
#include <Swift/Controllers/UIInterfaces/UserSearchWindow.h>
#include <Swift/Controllers/UIInterfaces/UserSearchWindowFactory.h>
#include <Swift/Controllers/Roster/RosterController.h>
namespace Swift {
UserSearchController::UserSearchController(Type type, const JID& jid, UIEventStream* uiEventStream, UserSearchWindowFactory* factory, IQRouter* iqRouter, RosterController* rosterController) : type_(type), jid_(jid), uiEventStream_(uiEventStream), factory_(factory), iqRouter_(iqRouter), rosterController_(rosterController) {
diff --git a/Swift/Controllers/FileTransfer/SOCKS5BytestreamProxyFinder.h b/Swift/Controllers/FileTransfer/SOCKS5BytestreamProxyFinder.h
index 1727a63..bffc7a1 100644
--- a/Swift/Controllers/FileTransfer/SOCKS5BytestreamProxyFinder.h
+++ b/Swift/Controllers/FileTransfer/SOCKS5BytestreamProxyFinder.h
@@ -2,19 +2,19 @@
* Copyright (c) 2011 Tobias Markmann
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
#pragma once
#include <boost/shared_ptr.hpp>
-#include <Swift/Controllers/DiscoServiceWalker.h>
+#include <Swiften/Disco/DiscoServiceWalker.h>
#include <Swiften/Network/HostAddressPort.h>
#include <Swiften/Elements/S5BProxyRequest.h>
namespace Swift {
class JID;
class IQRouter;
class SOCKS5BytestreamProxyFinder {
diff --git a/Swift/Controllers/SConscript b/Swift/Controllers/SConscript
index 289f055..03dc0b7 100644
--- a/Swift/Controllers/SConscript
+++ b/Swift/Controllers/SConscript
@@ -21,19 +21,18 @@ if env["SCONS_STAGE"] == "build" :
myenv.BuildVersion("BuildVersion.h", project = "swift")
myenv.MergeFlags(env["BOOST_FLAGS"])
myenv.StaticLibrary("SwiftControllers", [
"Chat/ChatController.cpp",
"Chat/ChatControllerBase.cpp",
"Chat/ChatsManager.cpp",
"Chat/MUCController.cpp",
"Chat/MUCSearchController.cpp",
"Chat/UserSearchController.cpp",
- "DiscoServiceWalker.cpp",
"MainController.cpp",
"ProfileController.cpp",
"ContactEditController.cpp",
"FileTransfer/FileTransferController.cpp",
"FileTransfer/FileTransferOverview.cpp",
"FileTransfer/FileTransferProgressInfo.cpp",
"FileTransfer/SOCKS5BytestreamProxyFinder.cpp",
"Roster/RosterController.cpp",
"Roster/RosterGroupExpandinessPersister.cpp",
diff --git a/Swift/Controllers/DiscoServiceWalker.cpp b/Swiften/Disco/DiscoServiceWalker.cpp
index 1ca4930..c8c3e1b 100644
--- a/Swift/Controllers/DiscoServiceWalker.cpp
+++ b/Swiften/Disco/DiscoServiceWalker.cpp
@@ -1,16 +1,17 @@
/*
* Copyright (c) 2010 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#include <Swift/Controllers/DiscoServiceWalker.h>
+#include <Swiften/Disco/DiscoServiceWalker.h>
+
#include <Swiften/Base/Log.h>
#include <Swiften/Base/foreach.h>
#include <boost/bind.hpp>
namespace Swift {
DiscoServiceWalker::DiscoServiceWalker(const JID& service, IQRouter* iqRouter, size_t maxSteps) : service_(service), iqRouter_(iqRouter), maxSteps_(maxSteps), active_(false) {
@@ -41,33 +42,18 @@ void DiscoServiceWalker::walkNode(const JID& jid) {
SWIFT_LOG(debug) << "Walking node " << jid << std::endl;
servicesBeingSearched_.insert(jid);
searchedServices_.insert(jid);
GetDiscoInfoRequest::ref discoInfoRequest = GetDiscoInfoRequest::create(jid, iqRouter_);
discoInfoRequest->onResponse.connect(boost::bind(&DiscoServiceWalker::handleDiscoInfoResponse, this, _1, _2, discoInfoRequest));
pendingDiscoInfoRequests_.insert(discoInfoRequest);
discoInfoRequest->send();
}
-void DiscoServiceWalker::handleReceivedDiscoItem(const JID& item) {
- SWIFT_LOG(debug) << "Received disco item " << item << std::endl;
-
- /* If we got canceled, don't do anything */
- if (!active_) {
- return;
- }
-
- if (std::find(searchedServices_.begin(), searchedServices_.end(), item) != searchedServices_.end()) {
- /* Don't recurse infinitely */
- return;
- }
- walkNode(item);
-}
-
void DiscoServiceWalker::handleDiscoInfoResponse(boost::shared_ptr<DiscoInfo> info, ErrorPayload::ref error, GetDiscoInfoRequest::ref request) {
/* If we got canceled, don't do anything */
if (!active_) {
return;
}
SWIFT_LOG(debug) << "Disco info response from " << request->getReceiver() << std::endl;
pendingDiscoInfoRequests_.erase(request);
@@ -97,54 +83,45 @@ void DiscoServiceWalker::handleDiscoInfoResponse(boost::shared_ptr<DiscoInfo> in
}
}
void DiscoServiceWalker::handleDiscoItemsResponse(boost::shared_ptr<DiscoItems> items, ErrorPayload::ref error, GetDiscoItemsRequest::ref request) {
/* If we got canceled, don't do anything */
if (!active_) {
return;
}
- SWIFT_LOG(debug) << "Received disco item from " << request->getReceiver() << std::endl;
-
+ SWIFT_LOG(debug) << "Received disco items from " << request->getReceiver() << std::endl;
pendingDiscoItemsRequests_.erase(request);
if (error) {
handleDiscoError(request->getReceiver(), error);
return;
}
foreach (DiscoItems::Item item, items->getItems()) {
if (item.getNode().empty()) {
/* Don't look at noded items. It's possible that this will exclude some services,
* but I've never seen one in the wild, and it's an easy fix for not looping.
*/
- handleReceivedDiscoItem(item.getJID());
+ if (std::find(searchedServices_.begin(), searchedServices_.end(), item.getJID()) == searchedServices_.end()) { /* Don't recurse infinitely */
+ SWIFT_LOG(debug) << "Received disco item " << item.getJID() << std::endl;
+ walkNode(item.getJID());
+ }
}
}
markNodeCompleted(request->getReceiver());
}
void DiscoServiceWalker::handleDiscoError(const JID& jid, ErrorPayload::ref /*error*/) {
- /* If we got canceled, don't do anything */
- if (!active_) {
- return;
- }
-
SWIFT_LOG(debug) << "Disco error from " << jid << std::endl;
-
markNodeCompleted(jid);
}
void DiscoServiceWalker::markNodeCompleted(const JID& jid) {
- // Check whether we weren't canceled in between a 'emit result' and this call
- if (!active_) {
- return;
- }
SWIFT_LOG(debug) << "Node completed " << jid << std::endl;
-
servicesBeingSearched_.erase(jid);
/* All results are in */
if (servicesBeingSearched_.empty()) {
active_ = false;
onWalkComplete();
}
/* Check if we're on a rampage */
else if (searchedServices_.size() >= maxSteps_) {
active_ = false;
diff --git a/Swift/Controllers/DiscoServiceWalker.h b/Swiften/Disco/DiscoServiceWalker.h
index 7982bbc..fd749fc 100644
--- a/Swift/Controllers/DiscoServiceWalker.h
+++ b/Swiften/Disco/DiscoServiceWalker.h
@@ -46,19 +46,18 @@ namespace Swift {
}
/** Emitted for each service found. */
boost::signal<void(const JID&, boost::shared_ptr<DiscoInfo>)> onServiceFound;
/** Emitted when walking is complete.*/
boost::signal<void()> onWalkComplete;
private:
- void handleReceivedDiscoItem(const JID& item);
void walkNode(const JID& jid);
void markNodeCompleted(const JID& jid);
void handleDiscoInfoResponse(boost::shared_ptr<DiscoInfo> info, ErrorPayload::ref error, GetDiscoInfoRequest::ref request);
void handleDiscoItemsResponse(boost::shared_ptr<DiscoItems> items, ErrorPayload::ref error, GetDiscoItemsRequest::ref request);
void handleDiscoError(const JID& jid, ErrorPayload::ref error);
private:
JID service_;
IQRouter* iqRouter_;
diff --git a/Swiften/Disco/SConscript b/Swiften/Disco/SConscript
index 434018a..c821b42 100644
--- a/Swiften/Disco/SConscript
+++ b/Swiften/Disco/SConscript
@@ -4,11 +4,12 @@ objects = swiften_env.SwiftenObject([
"CapsInfoGenerator.cpp",
"CapsManager.cpp",
"EntityCapsManager.cpp",
"EntityCapsProvider.cpp",
"DummyEntityCapsProvider.cpp",
"CapsStorage.cpp",
"ClientDiscoManager.cpp",
"DiscoInfoResponder.cpp",
"JIDDiscoInfoResponder.cpp",
+ "DiscoServiceWalker.cpp",
])
swiften_env.Append(SWIFTEN_OBJECTS = [objects])