diff options
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 2 | ||||
-rw-r--r-- | Swift/Controllers/UIEvents/CreateImpromptuMUCUIEvent.h | 10 | ||||
-rw-r--r-- | Swift/QtUI/UserSearch/QtUserSearchWindow.h | 52 |
3 files changed, 38 insertions, 26 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index 4f95d71..f55df1e 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -560,61 +560,61 @@ void ChatsManager::handleUIEvent(std::shared_ptr<UIEvent> event) { mucBookmarkManager_->removeBookmark(removeMUCBookmarkEvent->getBookmark()); return; } std::shared_ptr<AddMUCBookmarkUIEvent> addMUCBookmarkEvent = std::dynamic_pointer_cast<AddMUCBookmarkUIEvent>(event); if (addMUCBookmarkEvent) { mucBookmarkManager_->addBookmark(addMUCBookmarkEvent->getBookmark()); return; } std::shared_ptr<SendFileUIEvent> sendFileEvent = std::dynamic_pointer_cast<SendFileUIEvent>(event); if (sendFileEvent) { JID fileReceiver = sendFileEvent->getJID(); if (fileReceiver.isBare()) { // See if there is a chat controller for a conversation with a bound // full JID. Check if this JID supports file transfer and use it instead // of the bare JID. ChatController* controller = getChatControllerIfExists(fileReceiver, false); if (controller) { JID controllerJID = controller->getToJID(); if (!controllerJID.isBare() && (FeatureOracle(entityCapsProvider_, presenceOracle_).isFileTransferSupported(controllerJID) == Yes)) { fileReceiver = controllerJID; } } } ftOverview_->sendFile(fileReceiver, sendFileEvent->getFilename()); return; } std::shared_ptr<CreateImpromptuMUCUIEvent> createImpromptuMUCEvent = std::dynamic_pointer_cast<CreateImpromptuMUCUIEvent>(event); if (createImpromptuMUCEvent) { assert(!localMUCServiceJID_.toString().empty()); - // create new muc + // The room JID is random for new impromptu rooms, or a predefined JID for impromptu rooms resumed from the 'Recent chats' list. JID roomJID = createImpromptuMUCEvent->getRoomJID().toString().empty() ? JID(idGenerator_.generateID(), localMUCServiceJID_) : createImpromptuMUCEvent->getRoomJID(); // join muc MUC::ref muc = handleJoinMUCRequest(roomJID, boost::optional<std::string>(), nickResolver_->jidToNick(jid_), false, true, true); mucControllers_[roomJID]->onImpromptuConfigCompleted.connect(boost::bind(&ChatsManager::finalizeImpromptuJoin, this, muc, createImpromptuMUCEvent->getJIDs(), createImpromptuMUCEvent->getReason(), boost::optional<JID>())); mucControllers_[roomJID]->activateChatWindow(); } std::shared_ptr<EditMUCBookmarkUIEvent> editMUCBookmarkEvent = std::dynamic_pointer_cast<EditMUCBookmarkUIEvent>(event); if (editMUCBookmarkEvent) { mucBookmarkManager_->replaceBookmark(editMUCBookmarkEvent->getOldBookmark(), editMUCBookmarkEvent->getNewBookmark()); } else if (JoinMUCUIEvent::ref joinEvent = std::dynamic_pointer_cast<JoinMUCUIEvent>(event)) { handleJoinMUCRequest(joinEvent->getJID(), joinEvent->getPassword(), joinEvent->getNick(), joinEvent->getShouldJoinAutomatically(), joinEvent->getCreateAsReservedRoomIfNew(), joinEvent->isImpromptu()); mucControllers_[joinEvent->getJID()]->activateChatWindow(); } else if (std::shared_ptr<RequestJoinMUCUIEvent> joinEvent = std::dynamic_pointer_cast<RequestJoinMUCUIEvent>(event)) { if (!joinMUCWindow_) { joinMUCWindow_ = joinMUCWindowFactory_->createJoinMUCWindow(uiEventStream_); joinMUCWindow_->onSearchMUC.connect(boost::bind(&ChatsManager::handleSearchMUCRequest, this)); } joinMUCWindow_->setMUC(joinEvent->getRoom()); joinMUCWindow_->setNick(nickResolver_->jidToNick(jid_)); joinMUCWindow_->show(); } } void ChatsManager::markAllRecentsOffline() { for (ChatListWindow::Chat& chat : recentChats_) { chat.setStatusType(StatusShow::None); diff --git a/Swift/Controllers/UIEvents/CreateImpromptuMUCUIEvent.h b/Swift/Controllers/UIEvents/CreateImpromptuMUCUIEvent.h index 22ce926..e420bad 100644 --- a/Swift/Controllers/UIEvents/CreateImpromptuMUCUIEvent.h +++ b/Swift/Controllers/UIEvents/CreateImpromptuMUCUIEvent.h @@ -1,37 +1,47 @@ /* * Copyright (c) 2013 Tobias Markmann * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* * Copyright (c) 2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once #include <string> #include <vector> #include <Swiften/JID/JID.h> #include <Swift/Controllers/UIEvents/UIEvent.h> namespace Swift { class CreateImpromptuMUCUIEvent : public UIEvent { public: + /** + * @brief CreateImpromptuMUCUIEvent + * @param jids A vector of JIDs that are invited to the imprompto MUC. + * Useful when the event is used to recreate an old impromptu + * chat room. + * @param roomJID The full JID of the impromtu MUC. Useful when the event + * is used to recreate an old impromptu chat room. + * @param reason + */ CreateImpromptuMUCUIEvent(const std::vector<JID>& jids, const JID& roomJID = JID(), const std::string reason = "") : jids_(jids), roomJID_(roomJID), reason_(reason) { } std::vector<JID> getJIDs() const { return jids_; } JID getRoomJID() const { return roomJID_; } std::string getReason() const { return reason_; } + private: std::vector<JID> jids_; JID roomJID_; std::string reason_; }; } diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.h b/Swift/QtUI/UserSearch/QtUserSearchWindow.h index b9d4698..0714ac1 100644 --- a/Swift/QtUI/UserSearch/QtUserSearchWindow.h +++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.h @@ -1,96 +1,98 @@ /* * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once #include <set> #include <QWizard> +#include <Swiften/Base/Override.h> + #include <Swift/Controllers/UIInterfaces/UserSearchWindow.h> #include <Swift/QtUI/UserSearch/ui_QtUserSearchWizard.h> namespace Swift { class UserSearchModel; class UserSearchDelegate; class UserSearchResult; class UIEventStream; class QtUserSearchFirstPage; class QtUserSearchFirstMultiJIDPage; class QtUserSearchFieldsPage; class QtUserSearchResultsPage; class QtUserSearchDetailsPage; class QtFormResultItemModel; class SettingsProvider; class QtUserSearchWindow : public QWizard, public UserSearchWindow, private Ui::QtUserSearchWizard { Q_OBJECT public: QtUserSearchWindow(UIEventStream* eventStream, UserSearchWindow::Type type, const std::set<std::string>& groups, SettingsProvider* settingsProvider); virtual ~QtUserSearchWindow(); - virtual void addSavedServices(const std::vector<JID>& services); + virtual void addSavedServices(const std::vector<JID>& services) SWIFTEN_OVERRIDE; - virtual void clear(); - virtual void show(); - virtual void setResults(const std::vector<UserSearchResult>& results); - virtual void setResultsForm(Form::ref results); - virtual void setSelectedService(const JID& jid); - virtual void setServerSupportsSearch(bool error); - virtual void setSearchError(bool error); - virtual void setSearchFields(std::shared_ptr<SearchPayload> fields); - virtual void setNameSuggestions(const std::vector<std::string>& suggestions); - virtual void prepopulateJIDAndName(const JID& jid, const std::string& name); - virtual void setContactSuggestions(const std::vector<Contact::ref>& suggestions); - virtual void setJIDs(const std::vector<JID> &jids); - virtual void setOriginator(const JID& originator); - virtual void setRoomJID(const JID &roomJID); - virtual std::string getReason() const; - virtual std::vector<JID> getJIDs() const; - virtual void setCanStartImpromptuChats(bool supportsImpromptu); - virtual void updateContacts(const std::vector<Contact::ref> &contacts); - virtual void addContacts(const std::vector<Contact::ref>& contacts); - virtual void setCanSupplyDescription(bool allowed); - virtual void setWarning(const boost::optional<std::string>& message); + virtual void clear() SWIFTEN_OVERRIDE; + virtual void show() SWIFTEN_OVERRIDE; + virtual void setResults(const std::vector<UserSearchResult>& results) SWIFTEN_OVERRIDE; + virtual void setResultsForm(Form::ref results) SWIFTEN_OVERRIDE; + virtual void setSelectedService(const JID& jid) SWIFTEN_OVERRIDE; + virtual void setServerSupportsSearch(bool error) SWIFTEN_OVERRIDE; + virtual void setSearchError(bool error) SWIFTEN_OVERRIDE; + virtual void setSearchFields(std::shared_ptr<SearchPayload> fields) SWIFTEN_OVERRIDE; + virtual void setNameSuggestions(const std::vector<std::string>& suggestions) SWIFTEN_OVERRIDE; + virtual void prepopulateJIDAndName(const JID& jid, const std::string& name) SWIFTEN_OVERRIDE; + virtual void setContactSuggestions(const std::vector<Contact::ref>& suggestions) SWIFTEN_OVERRIDE; + virtual void setJIDs(const std::vector<JID> &jids) SWIFTEN_OVERRIDE; + virtual void setOriginator(const JID& originator) SWIFTEN_OVERRIDE; + virtual void setRoomJID(const JID &roomJID) SWIFTEN_OVERRIDE; + virtual std::string getReason() const SWIFTEN_OVERRIDE; + virtual std::vector<JID> getJIDs() const SWIFTEN_OVERRIDE; + virtual void setCanStartImpromptuChats(bool supportsImpromptu) SWIFTEN_OVERRIDE; + virtual void updateContacts(const std::vector<Contact::ref> &contacts) SWIFTEN_OVERRIDE; + virtual void addContacts(const std::vector<Contact::ref>& contacts) SWIFTEN_OVERRIDE; + virtual void setCanSupplyDescription(bool allowed) SWIFTEN_OVERRIDE; + virtual void setWarning(const boost::optional<std::string>& message) SWIFTEN_OVERRIDE; protected: - virtual int nextId() const; + virtual int nextId() const SWIFTEN_OVERRIDE; private slots: void handleFirstPageRadioChange(); - virtual void handleCurrentChanged(int); - virtual void handleAccepted(); + void handleCurrentChanged(int); + void handleAccepted(); void handleContactSuggestionRequested(const QString& text); void addContact(); void handleAddViaSearch(); void handleListChanged(std::vector<Contact::ref> list); void handleJIDsAdded(std::vector<JID> jids); void handleJIDEditingDone(); private: void setFirstPage(QString title = ""); void setSecondPage(); void setThirdPage(); private: void clearForm(); void setError(const QString& error); JID getServerToSearch(); void handleSearch(); JID getContactJID() const; Contact::ref getContact() const; void addSearchedJIDToList(const Contact::ref& contact); void handleOnSearchedJIDSelected(const Contact::ref& contact); private: UIEventStream* eventStream_; UserSearchWindow::Type type_; QAbstractItemModel* model_; UserSearchDelegate* delegate_; QtUserSearchFirstPage* firstPage_; QtUserSearchFirstMultiJIDPage* firstMultiJIDPage_; QtUserSearchFieldsPage* fieldsPage_; |