summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/AdHocManager.cpp13
-rw-r--r--Swift/Controllers/AdHocManager.h3
2 files changed, 11 insertions, 5 deletions
diff --git a/Swift/Controllers/AdHocManager.cpp b/Swift/Controllers/AdHocManager.cpp
index 368771f..0fa63a1 100644
--- a/Swift/Controllers/AdHocManager.cpp
+++ b/Swift/Controllers/AdHocManager.cpp
@@ -11,7 +11,6 @@
#include <Swiften/Base/foreach.h>
#include <Swiften/Queries/IQRouter.h>
-#include <Swiften/Disco/GetDiscoItemsRequest.h>
#include <Swiften/AdHoc/OutgoingAdHocCommandSession.h>
#include <Swift/Controllers/UIInterfaces/MainWindow.h>
#include <Swift/Controllers/UIInterfaces/AdHocCommandWindowFactory.h>
@@ -30,14 +29,18 @@ AdHocManager::AdHocManager(const JID& jid, AdHocCommandWindowFactory* factory, I
}
AdHocManager::~AdHocManager() {
-
+ uiEventStream_->onUIEvent.disconnect(boost::bind(&AdHocManager::handleUIEvent, this, _1));
}
void AdHocManager::setServerDiscoInfo(boost::shared_ptr<DiscoInfo> info) {
if (iqRouter_->isAvailable() && info->hasFeature(DiscoInfo::CommandsFeature)) {
- GetDiscoItemsRequest::ref discoItemsRequest = GetDiscoItemsRequest::create(JID(jid_.getDomain()), DiscoInfo::CommandsFeature, iqRouter_);
- discoItemsRequest->onResponse.connect(boost::bind(&AdHocManager::handleServerDiscoItemsResponse, this, _1, _2));
- discoItemsRequest->send();
+ if (discoItemsRequest_) {
+ discoItemsRequest_->onResponse.disconnect(boost::bind(&AdHocManager::handleServerDiscoItemsResponse, this, _1, _2));
+ discoItemsRequest_.reset();
+ }
+ discoItemsRequest_ = GetDiscoItemsRequest::create(JID(jid_.getDomain()), DiscoInfo::CommandsFeature, iqRouter_);
+ discoItemsRequest_->onResponse.connect(boost::bind(&AdHocManager::handleServerDiscoItemsResponse, this, _1, _2));
+ discoItemsRequest_->send();
} else {
mainWindow_->setAvailableAdHocCommands(std::vector<DiscoItems::Item>());
}
diff --git a/Swift/Controllers/AdHocManager.h b/Swift/Controllers/AdHocManager.h
index 9e21bf7..47b03cd 100644
--- a/Swift/Controllers/AdHocManager.h
+++ b/Swift/Controllers/AdHocManager.h
@@ -7,12 +7,14 @@
#pragma once
#include <boost/shared_ptr.hpp>
+#include <vector>
#include <Swiften/Base/boost_bsignals.h>
#include <Swiften/JID/JID.h>
#include <Swiften/Elements/DiscoInfo.h>
#include <Swiften/Elements/DiscoItems.h>
#include <Swiften/Elements/ErrorPayload.h>
+#include <Swiften/Disco/GetDiscoItemsRequest.h>
#include <Swift/Controllers/UIEvents/UIEvent.h>
namespace Swift {
@@ -33,5 +35,6 @@ namespace Swift {
UIEventStream* uiEventStream_;
MainWindow* mainWindow_;
AdHocCommandWindowFactory* factory_;
+ GetDiscoItemsRequest::ref discoItemsRequest_;
};
}