diff options
author | Kevin Smith <git@kismith.co.uk> | 2011-10-02 17:38:56 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2011-10-03 07:02:37 (GMT) |
commit | 4ea336d9d124f1c761b22943eaf6771e16a61e58 (patch) | |
tree | 7bcb7ac4366cf31a2f98654a5859de0b32fb318a /Swift/QtUI | |
parent | 123502d97dc20357ea03fd7f238f117aeb2d05c3 (diff) | |
download | swift-4ea336d9d124f1c761b22943eaf6771e16a61e58.zip swift-4ea336d9d124f1c761b22943eaf6771e16a61e58.tar.bz2 |
Simple MUC invites.
Resolves: #152
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 34 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.h | 1 |
2 files changed, 35 insertions, 0 deletions
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 50fe984..df78767 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -21,6 +21,7 @@ #include "SwifTools/TabComplete.h" #include <Swift/Controllers/UIEvents/UIEventStream.h> #include <Swift/Controllers/UIEvents/SendFileUIEvent.h> +#include <Swift/Controllers/UIEvents/JoinMUCUIEvent.h> #include "QtFileTransferJSBridge.h" #include <boost/cstdint.hpp> @@ -28,6 +29,7 @@ #include <boost/lexical_cast.hpp> #include <QLabel> +#include <QMessageBox> #include <QInputDialog> #include <QApplication> #include <QBoxLayout> @@ -702,6 +704,7 @@ void QtChatWindow::handleActionButtonClicked() { QAction* changeSubject = contextMenu.addAction(tr("Change subject")); QAction* configure = contextMenu.addAction(tr("Configure room")); QAction* destroy = contextMenu.addAction(tr("Destroy room")); + QAction* invite = contextMenu.addAction(tr("Invite person to this room")); QAction* result = contextMenu.exec(QCursor::pos()); if (result == changeSubject) { bool ok; @@ -716,6 +719,13 @@ void QtChatWindow::handleActionButtonClicked() { else if (result == destroy) { onDestroyRequest(); } + else if (result == invite) { + bool ok; + QString jid = QInputDialog::getText(this, tr("Enter person's address"), tr("Address:"), QLineEdit::Normal, "", &ok); + if (ok) { + onInvitePersonToThisMUCRequest(JID(Q2PSTRING(jid)), ""); + } + } } void QtChatWindow::showRoomConfigurationForm(Form::ref form) { @@ -726,4 +736,28 @@ void QtChatWindow::showRoomConfigurationForm(Form::ref form) { mucConfigurationWindow->onFormComplete.connect(boost::bind(boost::ref(onConfigureRequest), _1)); } +void QtChatWindow::addMUCInvitation(const JID& jid, const std::string& reason, const std::string& password) { + bool accepted = false; + QMessageBox msgBox; + msgBox.setText(QString("You have been invited to the room %1 by %2.").arg(P2QSTRING(jid.toString())).arg(contact_)); + QString reasonString; + if (!reason.empty()) { + reasonString = QString("\"%1\"").arg(P2QSTRING(reason)); + } + msgBox.setInformativeText(QString("Accept invitation from %1 to enter %2?\n%3").arg(contact_).arg(P2QSTRING(jid.toString())).arg(reasonString)); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::Yes); + int ret = msgBox.exec(); + switch (ret) { + case QMessageBox::Yes: + accepted = true; + break; + default: + break; + } + if (accepted) { + eventStream_->send(boost::make_shared<JoinMUCUIEvent>(jid)); + } +} + } diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index b011427..8dfe767 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -72,6 +72,7 @@ namespace Swift { virtual void setAvailableOccupantActions(const std::vector<OccupantAction>& actions); void setSubject(const std::string& subject); void showRoomConfigurationForm(Form::ref); + void addMUCInvitation(const JID& jid, const std::string& reason, const std::string& password); public slots: void handleChangeSplitterState(QByteArray state); |