summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-12-23 19:36:00 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-12-23 19:36:00 (GMT)
commit506d1621530a40d3e59f50f693587c3c4fd724f5 (patch)
treedfdd52d7b17ccfb372226192366bcb26d6bb6c0b /Swift/Controllers
parent135f55589ef230ab009e3b961895a6d3b12cdc87 (diff)
downloadswift-contrib-506d1621530a40d3e59f50f693587c3c4fd724f5.zip
swift-contrib-506d1621530a40d3e59f50f693587c3c4fd724f5.tar.bz2
Turn the 'Find other users' into seperate add/chat menu items with a wizard.
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/Chat/UserSearchController.cpp18
-rw-r--r--Swift/Controllers/Chat/UserSearchController.h4
-rw-r--r--Swift/Controllers/MainController.cpp12
-rw-r--r--Swift/Controllers/MainController.h3
-rw-r--r--Swift/Controllers/UIEvents/RequestAddUserDialogUIEvent.h (renamed from Swift/Controllers/UIEvents/RequestUserSearchUIEvent.h)2
-rw-r--r--Swift/Controllers/UIEvents/RequestChatWithUserDialogUIEvent.h15
-rw-r--r--Swift/Controllers/UIInterfaces/UserSearchWindow.h1
-rw-r--r--Swift/Controllers/UIInterfaces/UserSearchWindowFactory.h2
8 files changed, 44 insertions, 13 deletions
diff --git a/Swift/Controllers/Chat/UserSearchController.cpp b/Swift/Controllers/Chat/UserSearchController.cpp
index c3e40c8..886aa47 100644
--- a/Swift/Controllers/Chat/UserSearchController.cpp
+++ b/Swift/Controllers/Chat/UserSearchController.cpp
@@ -14,12 +14,13 @@
#include <Swift/Controllers/DiscoServiceWalker.h>
#include <Swift/Controllers/UIEvents/UIEventStream.h>
-#include <Swift/Controllers/UIEvents/RequestUserSearchUIEvent.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>
namespace Swift {
-UserSearchController::UserSearchController(const JID& jid, UIEventStream* uiEventStream, UserSearchWindowFactory* factory, IQRouter* iqRouter) : jid_(jid) {
+UserSearchController::UserSearchController(Type type, const JID& jid, UIEventStream* uiEventStream, UserSearchWindowFactory* factory, IQRouter* iqRouter) : type_(type), jid_(jid) {
iqRouter_ = iqRouter;
uiEventStream_ = uiEventStream;
uiEventConnection_ = uiEventStream_->onUIEvent.connect(boost::bind(&UserSearchController::handleUIEvent, this, _1));
@@ -34,10 +35,17 @@ UserSearchController::~UserSearchController() {
}
void UserSearchController::handleUIEvent(boost::shared_ptr<UIEvent> event) {
- boost::shared_ptr<RequestUserSearchUIEvent> searchEvent = boost::dynamic_pointer_cast<RequestUserSearchUIEvent>(event);
- if (searchEvent) {
+ bool handle = false;
+ if (type_ == AddContact) {
+ boost::shared_ptr<RequestAddUserDialogUIEvent> searchEvent = boost::dynamic_pointer_cast<RequestAddUserDialogUIEvent>(event);
+ if (searchEvent) handle = true;
+ } else {
+ boost::shared_ptr<RequestChatWithUserDialogUIEvent> searchEvent = boost::dynamic_pointer_cast<RequestChatWithUserDialogUIEvent>(event);
+ if (searchEvent) handle = true;
+ }
+ if (handle) {
if (!window_) {
- window_ = factory_->createUserSearchWindow(uiEventStream_);
+ window_ = factory_->createUserSearchWindow(type_ == AddContact ? UserSearchWindow::AddContact : UserSearchWindow::ChatToContact, uiEventStream_);
window_->onFormRequested.connect(boost::bind(&UserSearchController::handleFormRequested, this, _1));
window_->onSearchRequested.connect(boost::bind(&UserSearchController::handleSearch, this, _1, _2));
window_->setSelectedService(JID(jid_.getDomain()));
diff --git a/Swift/Controllers/Chat/UserSearchController.h b/Swift/Controllers/Chat/UserSearchController.h
index 3ba3352..c54b8d5 100644
--- a/Swift/Controllers/Chat/UserSearchController.h
+++ b/Swift/Controllers/Chat/UserSearchController.h
@@ -38,7 +38,8 @@ namespace Swift {
class UserSearchController {
public:
- UserSearchController(const JID& jid, UIEventStream* uiEventStream, UserSearchWindowFactory* userSearchWindowFactory, IQRouter* iqRouter);
+ enum Type {AddContact, StartChat};
+ UserSearchController(Type type, const JID& jid, UIEventStream* uiEventStream, UserSearchWindowFactory* userSearchWindowFactory, IQRouter* iqRouter);
~UserSearchController();
private:
void handleUIEvent(boost::shared_ptr<UIEvent> event);
@@ -48,6 +49,7 @@ namespace Swift {
void handleFormResponse(boost::shared_ptr<SearchPayload> items, ErrorPayload::ref error, const JID& jid);
void handleSearch(boost::shared_ptr<SearchPayload> fields, const JID& jid);
void handleSearchResponse(boost::shared_ptr<SearchPayload> results, ErrorPayload::ref error, const JID& jid);
+ Type type_;
UIEventStream* uiEventStream_;
UserSearchWindow* window_;
UserSearchWindowFactory* factory_;
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index 660c12f..ba8d944 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -99,7 +99,8 @@ MainController::MainController(
chatsManager_ = NULL;
eventWindowController_ = NULL;
mucSearchController_ = NULL;
- userSearchController_ = NULL;
+ userSearchControllerChat_ = NULL;
+ userSearchControllerAdd_ = NULL;
quitRequested_ = false;
timeBeforeNextReconnect_ = -1;
@@ -190,8 +191,10 @@ void MainController::resetClient() {
statusTracker_ = NULL;
delete profileSettings_;
profileSettings_ = NULL;
- delete userSearchController_;
- userSearchController_ = NULL;
+ delete userSearchControllerChat_;
+ userSearchControllerChat_ = NULL;
+ delete userSearchControllerAdd_;
+ userSearchControllerAdd_ = NULL;
}
void MainController::handleUIEvent(boost::shared_ptr<UIEvent> event) {
@@ -248,7 +251,8 @@ void MainController::handleConnected() {
mucSearchController_ = new MUCSearchController(jid_, uiEventStream_, uiFactory_, client_->getIQRouter(), settings_, client_->getNickResolver());
- userSearchController_ = new UserSearchController(jid_, uiEventStream_, uiFactory_, client_->getIQRouter());
+ userSearchControllerChat_ = new UserSearchController(UserSearchController::StartChat, jid_, uiEventStream_, uiFactory_, client_->getIQRouter());
+ userSearchControllerAdd_ = new UserSearchController(UserSearchController::AddContact, jid_, uiEventStream_, uiFactory_, client_->getIQRouter());
}
client_->requestRoster();
diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h
index 8489f71..f6a269d 100644
--- a/Swift/Controllers/MainController.h
+++ b/Swift/Controllers/MainController.h
@@ -139,7 +139,8 @@ namespace Swift {
boost::shared_ptr<ErrorEvent> lastDisconnectError_;
bool useDelayForLatency_;
MUCSearchController* mucSearchController_;
- UserSearchController* userSearchController_;
+ UserSearchController* userSearchControllerChat_;
+ UserSearchController* userSearchControllerAdd_;
int timeBeforeNextReconnect_;
Timer::ref reconnectTimer_;
Timer::ref quitTimer_;
diff --git a/Swift/Controllers/UIEvents/RequestUserSearchUIEvent.h b/Swift/Controllers/UIEvents/RequestAddUserDialogUIEvent.h
index 1312a84..bfa4a8b 100644
--- a/Swift/Controllers/UIEvents/RequestUserSearchUIEvent.h
+++ b/Swift/Controllers/UIEvents/RequestAddUserDialogUIEvent.h
@@ -9,7 +9,7 @@
#include "Swift/Controllers/UIEvents/UIEvent.h"
namespace Swift {
- class RequestUserSearchUIEvent : public UIEvent {
+ class RequestAddUserDialogUIEvent : public UIEvent {
};
}
diff --git a/Swift/Controllers/UIEvents/RequestChatWithUserDialogUIEvent.h b/Swift/Controllers/UIEvents/RequestChatWithUserDialogUIEvent.h
new file mode 100644
index 0000000..7b967bc
--- /dev/null
+++ b/Swift/Controllers/UIEvents/RequestChatWithUserDialogUIEvent.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include "Swift/Controllers/UIEvents/UIEvent.h"
+
+namespace Swift {
+ class RequestChatWithUserDialogUIEvent : public UIEvent {
+
+ };
+}
diff --git a/Swift/Controllers/UIInterfaces/UserSearchWindow.h b/Swift/Controllers/UIInterfaces/UserSearchWindow.h
index dda3409..e4a665b 100644
--- a/Swift/Controllers/UIInterfaces/UserSearchWindow.h
+++ b/Swift/Controllers/UIInterfaces/UserSearchWindow.h
@@ -18,6 +18,7 @@ namespace Swift {
class UserSearchWindow {
public:
+ enum Type {AddContact, ChatToContact};
virtual ~UserSearchWindow() {};
virtual void clear() = 0;
diff --git a/Swift/Controllers/UIInterfaces/UserSearchWindowFactory.h b/Swift/Controllers/UIInterfaces/UserSearchWindowFactory.h
index 808c1db..88e0a07 100644
--- a/Swift/Controllers/UIInterfaces/UserSearchWindowFactory.h
+++ b/Swift/Controllers/UIInterfaces/UserSearchWindowFactory.h
@@ -14,6 +14,6 @@ namespace Swift {
public:
virtual ~UserSearchWindowFactory() {};
- virtual UserSearchWindow* createUserSearchWindow(UIEventStream* eventStream) = 0;
+ virtual UserSearchWindow* createUserSearchWindow(UserSearchWindow::Type type, UIEventStream* eventStream) = 0;
};
}