diff options
author | dknn <yoann.blein@free.fr> | 2012-03-24 15:11:14 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2012-04-08 20:17:23 (GMT) |
commit | fe477c0da80c2e5799a1841ce7fcf4e023ad57bb (patch) | |
tree | 6aedfd75c47c64dee7fcf282e84ebafb6722c65d /Swift/Controllers/Chat | |
parent | 36eaae275b39340f44d8225a73ea129bc0c47464 (diff) | |
download | swift-contrib-fe477c0da80c2e5799a1841ce7fcf4e023ad57bb.zip swift-contrib-fe477c0da80c2e5799a1841ce7fcf4e023ad57bb.tar.bz2 |
'Add contact' from MUC right-click menu
This patch allows to add a contact from a MUC, by right clicking a contact in
the rooster. The action is only available if the JID of the user is also
available
License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r-- | Swift/Controllers/Chat/MUCController.cpp | 7 | ||||
-rw-r--r-- | Swift/Controllers/Chat/UserSearchController.cpp | 10 |
2 files changed, 16 insertions, 1 deletions
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index b8aa35c..fd37d27 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -22,6 +22,7 @@ #include <Swift/Controllers/UIInterfaces/ChatWindowFactory.h> #include <Swift/Controllers/UIEvents/UIEventStream.h> #include <Swift/Controllers/UIEvents/RequestChatUIEvent.h> +#include <Swift/Controllers/UIEvents/RequestAddUserDialogUIEvent.h> #include <Swift/Controllers/Roster/GroupRosterItem.h> #include <Swift/Controllers/Roster/ContactRosterItem.h> #include <Swiften/Avatars/AvatarManager.h> @@ -121,6 +122,11 @@ void MUCController::handleWindowOccupantSelectionChanged(ContactRosterItem* item actions.push_back(ChatWindow::MakeModerator); actions.push_back(ChatWindow::MakeParticipant); actions.push_back(ChatWindow::MakeVisitor); + + // Add contact is available only if the real JID is also available + if (muc_->getOccupant(item->getJID().getResource()).getRealJID()) { + actions.push_back(ChatWindow::AddContact); + } } chatWindow_->setAvailableOccupantActions(actions); } @@ -138,6 +144,7 @@ void MUCController::handleActionRequestedOnOccupant(ChatWindow::OccupantAction a case ChatWindow::MakeModerator: muc_->changeOccupantRole(mucJID, MUCOccupant::Moderator);break; case ChatWindow::MakeParticipant: muc_->changeOccupantRole(mucJID, MUCOccupant::Participant);break; case ChatWindow::MakeVisitor: muc_->changeOccupantRole(mucJID, MUCOccupant::Visitor);break; + case ChatWindow::AddContact: if (occupant.getRealJID()) events_->send(boost::make_shared<RequestAddUserDialogUIEvent>(realJID, occupant.getNick()));break; } } diff --git a/Swift/Controllers/Chat/UserSearchController.cpp b/Swift/Controllers/Chat/UserSearchController.cpp index af962e9..47d57d4 100644 --- a/Swift/Controllers/Chat/UserSearchController.cpp +++ b/Swift/Controllers/Chat/UserSearchController.cpp @@ -46,8 +46,9 @@ UserSearchController::~UserSearchController() { void UserSearchController::handleUIEvent(boost::shared_ptr<UIEvent> event) { bool handle = false; + boost::shared_ptr<RequestAddUserDialogUIEvent> request = boost::shared_ptr<RequestAddUserDialogUIEvent>(); if (type_ == AddContact) { - if (boost::dynamic_pointer_cast<RequestAddUserDialogUIEvent>(event)) { + if (request = boost::dynamic_pointer_cast<RequestAddUserDialogUIEvent>(event)) { handle = true; } } else { @@ -65,6 +66,13 @@ void UserSearchController::handleUIEvent(boost::shared_ptr<UIEvent> event) { window_->clear(); } window_->show(); + if (request) { + const std::string& name = request->getPredefinedName(); + const JID& jid = request->getPredefinedJID(); + if (!name.empty() && jid.isValid()) { + window_->prepopulateJIDAndName(jid, name); + } + } return; } } |