summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-06-09 18:38:59 (GMT)
committerKevin Smith <kevin.smith@isode.com>2015-07-07 16:18:16 (GMT)
commit4fa67e50ff57e2fd4bff80137c59d13e70a2f4a6 (patch)
tree77376e0a595aac8735324094ae4d07f1ece58a53 /Swift
parent2598ef4efcd74d5e9e701c62337bf84829572508 (diff)
downloadswift-4fa67e50ff57e2fd4bff80137c59d13e70a2f4a6.zip
swift-4fa67e50ff57e2fd4bff80137c59d13e70a2f4a6.tar.bz2
Add ability to enter rooms when offline
Rooms in the recent chats list and bookmarks can be entered by double click if the user is offline. They are joined when the user goes online again. Test-Information: Tested by going offline via the presence menu and then entering rooms via recent chats and bookmarks. Change-Id: I8c3eadd29c3353c2cf5f04f53b71ef7ad67a5c05
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/Chat/ChatsManager.cpp17
-rw-r--r--Swift/Controllers/Chat/MUCController.cpp9
-rw-r--r--Swift/QtUI/ChatList/QtChatListWindow.cpp8
3 files changed, 19 insertions, 15 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp
index 3cd9169..30870fa 100644
--- a/Swift/Controllers/Chat/ChatsManager.cpp
+++ b/Swift/Controllers/Chat/ChatsManager.cpp
@@ -688,8 +688,6 @@ void ChatsManager::setOnline(bool enabled) {
688 } 688 }
689 } 689 }
690 if (!enabled) { 690 if (!enabled) {
691 delete mucBookmarkManager_;
692 mucBookmarkManager_ = NULL;
693 chatListWindow_->setBookmarksEnabled(false); 691 chatListWindow_->setBookmarksEnabled(false);
694 markAllRecentsOffline(); 692 markAllRecentsOffline();
695 } else { 693 } else {
@@ -775,10 +773,6 @@ void ChatsManager::rebindControllerJID(const JID& from, const JID& to) {
775 773
776MUC::ref ChatsManager::handleJoinMUCRequest(const JID &mucJID, const boost::optional<std::string>& password, const boost::optional<std::string>& nickMaybe, bool addAutoJoin, bool createAsReservedIfNew, bool isImpromptu, ChatWindow* reuseChatwindow) { 774MUC::ref ChatsManager::handleJoinMUCRequest(const JID &mucJID, const boost::optional<std::string>& password, const boost::optional<std::string>& nickMaybe, bool addAutoJoin, bool createAsReservedIfNew, bool isImpromptu, ChatWindow* reuseChatwindow) {
777 MUC::ref muc; 775 MUC::ref muc;
778 if (!stanzaChannel_->isAvailable()) {
779 /* This is potentially not the optimal solution, but it will avoid consistency issues.*/
780 return muc;
781 }
782 if (addAutoJoin) { 776 if (addAutoJoin) {
783 MUCBookmark bookmark(mucJID, mucJID.getNode()); 777 MUCBookmark bookmark(mucJID, mucJID.getNode());
784 bookmark.setAutojoin(true); 778 bookmark.setAutojoin(true);
@@ -793,7 +787,9 @@ MUC::ref ChatsManager::handleJoinMUCRequest(const JID &mucJID, const boost::opti
793 787
794 std::map<JID, MUCController*>::iterator it = mucControllers_.find(mucJID); 788 std::map<JID, MUCController*>::iterator it = mucControllers_.find(mucJID);
795 if (it != mucControllers_.end()) { 789 if (it != mucControllers_.end()) {
796 it->second->rejoin(); 790 if (stanzaChannel_->isAvailable()) {
791 it->second->rejoin();
792 }
797 } else { 793 } else {
798 std::string nick = (nickMaybe && !(*nickMaybe).empty()) ? nickMaybe.get() : nickResolver_->jidToNick(jid_); 794 std::string nick = (nickMaybe && !(*nickMaybe).empty()) ? nickMaybe.get() : nickResolver_->jidToNick(jid_);
799 muc = mucManager->createMUC(mucJID); 795 muc = mucManager->createMUC(mucJID);
@@ -825,6 +821,13 @@ MUC::ref ChatsManager::handleJoinMUCRequest(const JID &mucJID, const boost::opti
825 controller->onUserNicknameChanged.connect(boost::bind(&ChatsManager::handleUserNicknameChanged, this, controller, _1, _2)); 821 controller->onUserNicknameChanged.connect(boost::bind(&ChatsManager::handleUserNicknameChanged, this, controller, _1, _2));
826 controller->onActivity.connect(boost::bind(&ChatsManager::handleChatActivity, this, mucJID.toBare(), _1, true)); 822 controller->onActivity.connect(boost::bind(&ChatsManager::handleChatActivity, this, mucJID.toBare(), _1, true));
827 controller->onUnreadCountChanged.connect(boost::bind(&ChatsManager::handleUnreadCountChanged, this, controller)); 823 controller->onUnreadCountChanged.connect(boost::bind(&ChatsManager::handleUnreadCountChanged, this, controller));
824 if (!stanzaChannel_->isAvailable()) {
825 /* When online, the MUC is added to the registry in MUCImpl::internalJoin. This method is not
826 * called when Swift is offline, so we add it here as only MUCs in the registry are rejoined
827 * when going back online.
828 */
829 mucRegistry_->addMUC(mucJID.toBare());
830 }
828 handleChatActivity(mucJID.toBare(), "", true); 831 handleChatActivity(mucJID.toBare(), "", true);
829 } 832 }
830 833
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp
index 5788465..c9936c0 100644
--- a/Swift/Controllers/Chat/MUCController.cpp
+++ b/Swift/Controllers/Chat/MUCController.cpp
@@ -133,11 +133,14 @@ MUCController::MUCController (
133 muc_->onConfigurationFormReceived.connect(boost::bind(&MUCController::handleConfigurationFormReceived, this, _1)); 133 muc_->onConfigurationFormReceived.connect(boost::bind(&MUCController::handleConfigurationFormReceived, this, _1));
134 highlighter_->setMode(isImpromptu_ ? Highlighter::ChatMode : Highlighter::MUCMode); 134 highlighter_->setMode(isImpromptu_ ? Highlighter::ChatMode : Highlighter::MUCMode);
135 highlighter_->setNick(nick_); 135 highlighter_->setNick(nick_);
136 if (timerFactory) { 136 if (timerFactory && stanzaChannel_->isAvailable()) {
137 loginCheckTimer_ = boost::shared_ptr<Timer>(timerFactory->createTimer(MUC_JOIN_WARNING_TIMEOUT_MILLISECONDS)); 137 loginCheckTimer_ = boost::shared_ptr<Timer>(timerFactory->createTimer(MUC_JOIN_WARNING_TIMEOUT_MILLISECONDS));
138 loginCheckTimer_->onTick.connect(boost::bind(&MUCController::handleJoinTimeoutTick, this)); 138 loginCheckTimer_->onTick.connect(boost::bind(&MUCController::handleJoinTimeoutTick, this));
139 loginCheckTimer_->start(); 139 loginCheckTimer_->start();
140 } 140 }
141 else {
142 chatWindow_->addSystemMessage(chatMessageParser_->parseMessageBody(QT_TRANSLATE_NOOP("", "You are currently offline. You will enter this room when you are connected.")), ChatWindow::DefaultDirection);
143 }
141 if (isImpromptu) { 144 if (isImpromptu) {
142 muc_->onUnlocked.connect(boost::bind(&MUCController::handleRoomUnlocked, this)); 145 muc_->onUnlocked.connect(boost::bind(&MUCController::handleRoomUnlocked, this));
143 chatWindow_->convertToMUC(ChatWindow::ImpromptuMUC); 146 chatWindow_->convertToMUC(ChatWindow::ImpromptuMUC);
@@ -147,7 +150,9 @@ MUCController::MUCController (
147 chatWindow_->convertToMUC(ChatWindow::StandardMUC); 150 chatWindow_->convertToMUC(ChatWindow::StandardMUC);
148 chatWindow_->setName(muc->getJID().getNode()); 151 chatWindow_->setName(muc->getJID().getNode());
149 } 152 }
150 setOnline(true); 153 if (stanzaChannel->isAvailable()) {
154 setOnline(true);
155 }
151 if (avatarManager_ != NULL) { 156 if (avatarManager_ != NULL) {
152 avatarChangedConnection_ = (avatarManager_->onAvatarChanged.connect(boost::bind(&MUCController::handleAvatarChanged, this, _1))); 157 avatarChangedConnection_ = (avatarManager_->onAvatarChanged.connect(boost::bind(&MUCController::handleAvatarChanged, this, _1)));
153 } 158 }
diff --git a/Swift/QtUI/ChatList/QtChatListWindow.cpp b/Swift/QtUI/ChatList/QtChatListWindow.cpp
index 7b40f9c..b990b84 100644
--- a/Swift/QtUI/ChatList/QtChatListWindow.cpp
+++ b/Swift/QtUI/ChatList/QtChatListWindow.cpp
@@ -96,14 +96,10 @@ void QtChatListWindow::setupContextMenus() {
96void QtChatListWindow::handleItemActivated(const QModelIndex& index) { 96void QtChatListWindow::handleItemActivated(const QModelIndex& index) {
97 ChatListItem* item = model_->getItemForIndex(index); 97 ChatListItem* item = model_->getItemForIndex(index);
98 if (ChatListMUCItem* mucItem = dynamic_cast<ChatListMUCItem*>(item)) { 98 if (ChatListMUCItem* mucItem = dynamic_cast<ChatListMUCItem*>(item)) {
99 if (bookmarksEnabled_) { 99 onMUCBookmarkActivated(mucItem->getBookmark());
100 onMUCBookmarkActivated(mucItem->getBookmark());
101 }
102 } 100 }
103 else if (ChatListRecentItem* recentItem = dynamic_cast<ChatListRecentItem*>(item)) { 101 else if (ChatListRecentItem* recentItem = dynamic_cast<ChatListRecentItem*>(item)) {
104 if (!recentItem->getChat().isMUC || bookmarksEnabled_) { 102 onRecentActivated(recentItem->getChat());
105 onRecentActivated(recentItem->getChat());
106 }
107 } 103 }
108 else if (ChatListWhiteboardItem* whiteboardItem = dynamic_cast<ChatListWhiteboardItem*>(item)) { 104 else if (ChatListWhiteboardItem* whiteboardItem = dynamic_cast<ChatListWhiteboardItem*>(item)) {
109 if (!whiteboardItem->getChat().isMUC || bookmarksEnabled_) { 105 if (!whiteboardItem->getChat().isMUC || bookmarksEnabled_) {