diff options
author | Kevin Smith <git@kismith.co.uk> | 2012-04-27 14:58:37 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2012-04-27 14:58:37 (GMT) |
commit | 9e57b31133edad6a543da05aca54ee94d589b090 (patch) | |
tree | 85b5fa4c4669677a5b4e6d263bbf153077bee357 /Swift/Controllers | |
parent | c1944713513ae5262e9960a7ef391f4bb915e999 (diff) | |
download | swift-contrib-9e57b31133edad6a543da05aca54ee94d589b090.zip swift-contrib-9e57b31133edad6a543da05aca54ee94d589b090.tar.bz2 |
Reset state of collapsing presence when a chat window is cleared.
To stop new presence being lost because it's trying to append to old (deleted) data.
Resolves: #925
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/Chat/ChatController.cpp | 4 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatController.h | 3 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatControllerBase.cpp | 5 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatControllerBase.h | 2 | ||||
-rw-r--r-- | Swift/Controllers/Chat/MUCController.cpp | 4 | ||||
-rw-r--r-- | Swift/Controllers/Chat/MUCController.h | 1 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/ChatWindow.h | 7 |
7 files changed, 22 insertions, 4 deletions
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index 3f16071..5a18a98 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -91,6 +91,10 @@ ChatController::~ChatController() { delete chatStateTracker_; } +void ChatController::cancelReplaces() { + lastWasPresence_ = false; +} + void ChatController::handleBareJIDCapsChanged(const JID& /*jid*/) { DiscoInfo::ref disco = entityCapsProvider_->getCaps(toJID_); if (disco) { diff --git a/Swift/Controllers/Chat/ChatController.h b/Swift/Controllers/Chat/ChatController.h index 2a66772..00d167e 100644 --- a/Swift/Controllers/Chat/ChatController.h +++ b/Swift/Controllers/Chat/ChatController.h @@ -31,6 +31,9 @@ namespace Swift { virtual void handleNewFileTransferController(FileTransferController* ftc); virtual void setContactIsReceivingPresence(bool /*isReceivingPresence*/); + protected: + void cancelReplaces(); + private: void handlePresenceChange(boost::shared_ptr<Presence> newPresence); std::string getStatusChangeString(boost::shared_ptr<Presence> presence); diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp index 583a102..3ff52a6 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.cpp +++ b/Swift/Controllers/Chat/ChatControllerBase.cpp @@ -37,6 +37,7 @@ ChatControllerBase::ChatControllerBase(const JID& self, StanzaChannel* stanzaCha chatWindow_ = chatWindowFactory_->createChatWindow(toJID, eventStream); chatWindow_->onAllMessagesRead.connect(boost::bind(&ChatControllerBase::handleAllMessagesRead, this)); chatWindow_->onSendMessageRequest.connect(boost::bind(&ChatControllerBase::handleSendMessageRequest, this, _1, _2)); + chatWindow_->onLogCleared.connect(boost::bind(&ChatControllerBase::handleLogCleared, this)); entityCapsProvider_->onCapsChanged.connect(boost::bind(&ChatControllerBase::handleCapsChanged, this, _1)); setOnline(stanzaChannel->isAvailable() && iqRouter->isAvailable()); createDayChangeTimer(); @@ -46,6 +47,10 @@ ChatControllerBase::~ChatControllerBase() { delete chatWindow_; } +void ChatControllerBase::handleLogCleared() { + cancelReplaces(); +} + void ChatControllerBase::handleCapsChanged(const JID& jid) { if (jid.compare(toJID_, JID::WithoutResource) == 0) { handleBareJIDCapsChanged(jid); diff --git a/Swift/Controllers/Chat/ChatControllerBase.h b/Swift/Controllers/Chat/ChatControllerBase.h index 7dd339c..8654311 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.h +++ b/Swift/Controllers/Chat/ChatControllerBase.h @@ -75,6 +75,7 @@ namespace Swift { virtual void handleBareJIDCapsChanged(const JID& jid) = 0; std::string getErrorMessage(boost::shared_ptr<ErrorPayload>); virtual void setContactIsReceivingPresence(bool /* isReceivingPresence */) {} + virtual void cancelReplaces() = 0; private: IDGenerator idGenerator_; @@ -87,6 +88,7 @@ namespace Swift { void handleMUCInvitation(Message::ref message); void handleMediatedMUCInvitation(Message::ref message); void handleGeneralMUCInvitation(MUCInviteEvent::ref event); + void handleLogCleared(); protected: JID selfJID_; diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 3386877..e4209f4 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -114,6 +114,10 @@ MUCController::~MUCController() { delete completer_; } +void MUCController::cancelReplaces() { + lastWasPresence_ = false; +} + void MUCController::handleWindowOccupantSelectionChanged(ContactRosterItem* item) { std::vector<ChatWindow::OccupantAction> actions; diff --git a/Swift/Controllers/Chat/MUCController.h b/Swift/Controllers/Chat/MUCController.h index c2a5103..9550ca9 100644 --- a/Swift/Controllers/Chat/MUCController.h +++ b/Swift/Controllers/Chat/MUCController.h @@ -61,6 +61,7 @@ namespace Swift { boost::optional<boost::posix_time::ptime> getMessageTimestamp(boost::shared_ptr<Message> message) const; void preHandleIncomingMessage(boost::shared_ptr<MessageEvent>); void postHandleIncomingMessage(boost::shared_ptr<MessageEvent>); + void cancelReplaces(); private: void setAvailableRoomActions(const MUCOccupant::Affiliation& affiliation, const MUCOccupant::Role& role); diff --git a/Swift/Controllers/UIInterfaces/ChatWindow.h b/Swift/Controllers/UIInterfaces/ChatWindow.h index 2986de1..b5b1604 100644 --- a/Swift/Controllers/UIInterfaces/ChatWindow.h +++ b/Swift/Controllers/UIInterfaces/ChatWindow.h @@ -1,11 +1,10 @@ /* - * Copyright (c) 2010 Kevin Smith + * Copyright (c) 2010-2012 Kevin Smith * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ -#ifndef SWIFTEN_CHATWINDOW_H -#define SWIFTEN_CHATWINDOW_H +#pragma once #include <boost/optional.hpp> #include "Swiften/Base/boost_bsignals.h" @@ -123,6 +122,7 @@ namespace Swift { boost::signal<void ()> onGetAffiliationsRequest; boost::signal<void (MUCOccupant::Affiliation, const JID&)> onSetAffiliationRequest; boost::signal<void (const std::vector<std::pair<MUCOccupant::Affiliation, JID> >& changes)> onChangeAffiliationsRequest; + boost::signal<void ()> onLogCleared; // File transfer related boost::signal<void (std::string /* id */)> onFileTransferCancel; @@ -131,5 +131,4 @@ namespace Swift { boost::signal<void (std::string /* path */)> onSendFileRequest; }; } -#endif |