summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-05-31 21:13:00 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-06-04 19:34:04 (GMT)
commitecd4309da49ad3186ae829b7c8b50eb78f856249 (patch)
tree35ef94e86b6e631a92d38652bc6b4f1ec618035e /Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
parentfee6af7cc3a8a64fb5d3dbf5e2aaf73a6052ccf1 (diff)
downloadswift-ecd4309da49ad3186ae829b7c8b50eb78f856249.zip
swift-ecd4309da49ad3186ae829b7c8b50eb78f856249.tar.bz2
Add option to autojoin when joining a room.
Resolves: #380
Diffstat (limited to 'Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp')
-rw-r--r--Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
index a8bf9ee..b1cfd65 100644
--- a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
+++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
@@ -10,6 +10,7 @@
#include "Swift/Controllers/UIEvents/UIEventStream.h"
#include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h"
+#include "Swift/Controllers/UIEvents/AddMUCBookmarkUIEvent.h"
#include "Swift/QtUI/MUCSearch/MUCSearchModel.h"
#include "Swift/QtUI/MUCSearch/MUCSearchDelegate.h"
#include "Swift/QtUI/QtSwiftUtil.h"
@@ -79,14 +80,37 @@ void QtMUCSearchWindow::handleJoin() {
}
boost::optional<String> maybeNick;
if (!nickName_->text().isEmpty()) {
- maybeNick = Q2PSTRING(nickName_->text());
+ lastSetNick_ = Q2PSTRING(nickName_->text());
+ maybeNick = lastSetNick_;
}
- eventStream_->send(boost::shared_ptr<UIEvent>(new JoinMUCUIEvent(JID(Q2PSTRING(room_->text())), maybeNick)));
+
+ JID room(Q2PSTRING(room_->text()));
+ if (joinAutomatically_->isChecked()) {
+ createAutoJoin(room, maybeNick);
+ }
+ eventStream_->send(boost::shared_ptr<UIEvent>(new JoinMUCUIEvent(room, maybeNick)));
hide();
}
+void QtMUCSearchWindow::createAutoJoin(const JID& room, boost::optional<String> passedNick) {
+ String nick = lastSetNick_;
+ if (passedNick) {
+ nick = passedNick.get();
+ }
+ MUCBookmark bookmark(room, room.getNode());
+ bookmark.setAutojoin(true);
+ if (!nick.isEmpty()) {
+ bookmark.setNick(nick);
+ }
+ //if (!password.isEmpty()) {
+ // bookmark.setPassword(password);
+ //}
+ eventStream_->send(boost::shared_ptr<UIEvent>(new AddMUCBookmarkUIEvent(bookmark)));
+}
+
void QtMUCSearchWindow::setNick(const String& nick) {
nickName_->setText(P2QSTRING(nick));
+ lastSetNick_ = nick;
}
void QtMUCSearchWindow::setMUC(const String& nick) {