summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-05-31 17:27:48 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-05-31 17:30:34 (GMT)
commit6aeb44a905b0c1955ea3afe4ea2025370544e699 (patch)
treef5d99af0cd87d628263643dc2aa98353d3d3b78d /Swift/Controllers/Chat
parent59f1bfcf315a77834ddbce20cc05892d211ab55c (diff)
downloadswift-contrib-6aeb44a905b0c1955ea3afe4ea2025370544e699.zip
swift-contrib-6aeb44a905b0c1955ea3afe4ea2025370544e699.tar.bz2
Very poor prototype of a MUC invite dialog
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r--Swift/Controllers/Chat/MUCController.cpp22
-rw-r--r--Swift/Controllers/Chat/MUCController.h6
2 files changed, 24 insertions, 4 deletions
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp
index e4209f4..3d04b34 100644
--- a/Swift/Controllers/Chat/MUCController.cpp
+++ b/Swift/Controllers/Chat/MUCController.cpp
@@ -19,6 +19,7 @@
#include <Swiften/Base/foreach.h>
#include <Swift/Controllers/XMPPEvents/EventController.h>
#include <Swift/Controllers/UIInterfaces/ChatWindow.h>
+#include <Swift/Controllers/UIInterfaces/InviteToChatWindow.h>
#include <Swift/Controllers/UIInterfaces/ChatWindowFactory.h>
#include <Swift/Controllers/UIEvents/UIEventStream.h>
#include <Swift/Controllers/UIEvents/RequestChatUIEvent.h>
@@ -64,6 +65,7 @@ MUCController::MUCController (
shouldJoinOnReconnect_ = true;
doneGettingHistory_ = false;
events_ = uiEventStream;
+ inviteWindow_ = NULL;
roster_ = new Roster(false, true);
completer_ = new TabComplete();
@@ -77,7 +79,7 @@ MUCController::MUCController (
chatWindow_->onConfigureRequest.connect(boost::bind(&MUCController::handleConfigureRequest, this, _1));
chatWindow_->onConfigurationFormCancelled.connect(boost::bind(&MUCController::handleConfigurationCancelled, this));
chatWindow_->onDestroyRequest.connect(boost::bind(&MUCController::handleDestroyRoomRequest, this));
- chatWindow_->onInvitePersonToThisMUCRequest.connect(boost::bind(&MUCController::handleInvitePersonToThisMUCRequest, this, _1, _2));
+ chatWindow_->onInvitePersonToThisMUCRequest.connect(boost::bind(&MUCController::handleInvitePersonToThisMUCRequest, this));
chatWindow_->onGetAffiliationsRequest.connect(boost::bind(&MUCController::handleGetAffiliationsRequest, this));
chatWindow_->onChangeAffiliationsRequest.connect(boost::bind(&MUCController::handleChangeAffiliationsRequest, this, _1));
muc_->onJoinComplete.connect(boost::bind(&MUCController::handleJoinComplete, this, _1));
@@ -719,8 +721,22 @@ void MUCController::handleDestroyRoomRequest() {
muc_->destroyRoom();
}
-void MUCController::handleInvitePersonToThisMUCRequest(const JID& jid, const std::string& reason) {
- muc_->invitePerson(jid, reason);
+void MUCController::handleInvitePersonToThisMUCRequest() {
+ if (!inviteWindow_) {
+ inviteWindow_ = chatWindow_->createInviteToChatWindow();
+ inviteWindow_->onCompleted.connect(boost::bind(&MUCController::handleInviteToMUCWindowCompleted, this));
+ inviteWindow_->onDismissed.connect(boost::bind(&MUCController::handleInviteToMUCWindowDismissed, this));
+ }
+}
+
+void MUCController::handleInviteToMUCWindowDismissed() {
+ inviteWindow_= NULL;
+}
+
+void MUCController::handleInviteToMUCWindowCompleted() {
+ foreach (const JID& jid, inviteWindow_->getJIDs()) {
+ muc_->invitePerson(jid, inviteWindow_->getReason());
+ }
}
void MUCController::handleGetAffiliationsRequest() {
diff --git a/Swift/Controllers/Chat/MUCController.h b/Swift/Controllers/Chat/MUCController.h
index 9550ca9..8b43dcf 100644
--- a/Swift/Controllers/Chat/MUCController.h
+++ b/Swift/Controllers/Chat/MUCController.h
@@ -31,6 +31,7 @@ namespace Swift {
class UIEventStream;
class TimerFactory;
class TabComplete;
+ class InviteToChatWindow;
enum JoinPart {Join, Part, JoinThenPart, PartThenJoin};
@@ -95,12 +96,14 @@ namespace Swift {
void handleConfigurationFailed(ErrorPayload::ref);
void handleConfigurationFormReceived(Form::ref);
void handleDestroyRoomRequest();
- void handleInvitePersonToThisMUCRequest(const JID& jid, const std::string& reason);
+ void handleInvitePersonToThisMUCRequest();
void handleConfigurationCancelled();
void handleOccupantRoleChangeFailed(ErrorPayload::ref, const JID&, MUCOccupant::Role);
void handleGetAffiliationsRequest();
void handleAffiliationListReceived(MUCOccupant::Affiliation affiliation, const std::vector<JID>& jids);
void handleChangeAffiliationsRequest(const std::vector<std::pair<MUCOccupant::Affiliation, JID> >& changes);
+ void handleInviteToMUCWindowDismissed();
+ void handleInviteToMUCWindowCompleted();
private:
MUC::ref muc_;
@@ -120,6 +123,7 @@ namespace Swift {
std::vector<NickJoinPart> joinParts_;
boost::posix_time::ptime lastActivity_;
boost::optional<std::string> password_;
+ InviteToChatWindow* inviteWindow_;
};
}