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
@@ -17,7 +17,7 @@
#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 {
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
@@ -12,7 +12,7 @@
#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>
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
@@ -8,7 +8,7 @@
#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>
diff --git a/Swift/Controllers/SConscript b/Swift/Controllers/SConscript
index 289f055..03dc0b7 100644
--- a/Swift/Controllers/SConscript
+++ b/Swift/Controllers/SConscript
@@ -27,7 +27,6 @@ if env["SCONS_STAGE"] == "build" :
"Chat/MUCController.cpp",
"Chat/MUCSearchController.cpp",
"Chat/UserSearchController.cpp",
- "DiscoServiceWalker.cpp",
"MainController.cpp",
"ProfileController.cpp",
"ContactEditController.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
@@ -4,7 +4,8 @@
* 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>
@@ -47,21 +48,6 @@ void DiscoServiceWalker::walkNode(const JID& jid) {
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_) {
@@ -103,8 +89,7 @@ void DiscoServiceWalker::handleDiscoItemsResponse(boost::shared_ptr<DiscoItems>
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);
@@ -115,30 +100,22 @@ void DiscoServiceWalker::handleDiscoItemsResponse(boost::shared_ptr<DiscoItems>
/* 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()) {
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
@@ -52,7 +52,6 @@ namespace Swift {
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);
diff --git a/Swiften/Disco/SConscript b/Swiften/Disco/SConscript
index 434018a..c821b42 100644
--- a/Swiften/Disco/SConscript
+++ b/Swiften/Disco/SConscript
@@ -10,5 +10,6 @@ objects = swiften_env.SwiftenObject([
"ClientDiscoManager.cpp",
"DiscoInfoResponder.cpp",
"JIDDiscoInfoResponder.cpp",
+ "DiscoServiceWalker.cpp",
])
swiften_env.Append(SWIFTEN_OBJECTS = [objects])