diff options
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/Controllers/Chat/ChatController.cpp | 2 | ||||
-rw-r--r-- | Swift/Controllers/Chat/MUCController.cpp | 4 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/ChatWindow.h | 3 | ||||
-rw-r--r-- | Swift/Controllers/UnitTest/MockChatWindow.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/QtChatView.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 4 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/QtPlainChatView.cpp | 2 | ||||
-rw-r--r-- | Swift/QtUI/QtPlainChatView.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/QtWebKitChatView.cpp | 13 | ||||
-rw-r--r-- | Swift/QtUI/QtWebKitChatView.h | 4 |
11 files changed, 23 insertions, 17 deletions
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index 65d65a6..2367761 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -478,7 +478,7 @@ void ChatController::handlePresenceChange(boost::shared_ptr<Presence> newPresenc std::string newStatusChangeString = getStatusChangeString(newPresence); if (newStatusChangeString != lastStatusChangeString_) { if (lastWasPresence_) { - chatWindow_->replaceLastMessage(chatMessageParser_->parseMessageBody(newStatusChangeString)); + chatWindow_->replaceLastMessage(chatMessageParser_->parseMessageBody(newStatusChangeString), ChatWindow::UpdateTimestamp); } else { chatWindow_->addPresenceMessage(chatMessageParser_->parseMessageBody(newStatusChangeString), ChatWindow::DefaultDirection); } diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 6bc7067..d09bc3d 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -344,7 +344,7 @@ void MUCController::handleJoinComplete(const std::string& nick) { joinMessage = str(format(QT_TRANSLATE_NOOP("", "You have entered room %1% as %2%.")) % toJID_.toString() % nick); } setNick(nick); - chatWindow_->replaceLastMessage(chatMessageParser_->parseMessageBody(joinMessage)); + chatWindow_->replaceLastMessage(chatMessageParser_->parseMessageBody(joinMessage), ChatWindow::UpdateTimestamp); #ifdef SWIFT_EXPERIMENTAL_HISTORY addRecentLogs(); @@ -714,7 +714,7 @@ boost::optional<boost::posix_time::ptime> MUCController::getMessageTimestamp(boo } void MUCController::updateJoinParts() { - chatWindow_->replaceLastMessage(chatMessageParser_->parseMessageBody(generateJoinPartString(joinParts_, isImpromptu()))); + chatWindow_->replaceLastMessage(chatMessageParser_->parseMessageBody(generateJoinPartString(joinParts_, isImpromptu())), ChatWindow::UpdateTimestamp); } void MUCController::appendToJoinParts(std::vector<NickJoinPart>& joinParts, const NickJoinPart& newEvent) { diff --git a/Swift/Controllers/UIInterfaces/ChatWindow.h b/Swift/Controllers/UIInterfaces/ChatWindow.h index ba4b397..bf4744b 100644 --- a/Swift/Controllers/UIInterfaces/ChatWindow.h +++ b/Swift/Controllers/UIInterfaces/ChatWindow.h @@ -94,6 +94,7 @@ namespace Swift { enum BlockingState {BlockingUnsupported, IsBlocked, IsUnblocked}; enum Direction { UnknownDirection, DefaultDirection }; enum MUCType { StandardMUC, ImpromptuMUC }; + enum TimestampBehaviour { KeepTimestamp, UpdateTimestamp }; ChatWindow() {} virtual ~ChatWindow() {} @@ -142,7 +143,7 @@ namespace Swift { virtual void setInputEnabled(bool enabled) = 0; virtual void setRosterModel(Roster* model) = 0; virtual void setTabComplete(TabComplete* completer) = 0; - virtual void replaceLastMessage(const ChatMessage& message) = 0; + virtual void replaceLastMessage(const ChatMessage& message, const TimestampBehaviour timestampBehaviour) = 0; virtual void setAckState(const std::string& id, AckState state) = 0; virtual void flash() = 0; virtual void setSubject(const std::string& subject) = 0; diff --git a/Swift/Controllers/UnitTest/MockChatWindow.h b/Swift/Controllers/UnitTest/MockChatWindow.h index e4c2548..823ea3a 100644 --- a/Swift/Controllers/UnitTest/MockChatWindow.h +++ b/Swift/Controllers/UnitTest/MockChatWindow.h @@ -29,7 +29,7 @@ namespace Swift { virtual void addErrorMessage(const ChatMessage& /*message*/) {} virtual void replaceMessage(const ChatMessage& /*message*/, const std::string& /*id*/, const boost::posix_time::ptime& /*time*/, const HighlightAction& /*highlight*/) {} virtual void replaceWithAction(const ChatMessage& /*message*/, const std::string& /*id*/, const boost::posix_time::ptime& /*time*/, const HighlightAction& /*highlight*/) {} - virtual void replaceLastMessage(const ChatMessage& /*message*/) {} + virtual void replaceLastMessage(const ChatMessage& /*message*/, const TimestampBehaviour /*timestampBehaviour*/) {} // File transfer related stuff virtual std::string addFileTransfer(const std::string& /*senderName*/, bool /*senderIsSelf*/,const std::string& /*filename*/, const boost::uintmax_t /*sizeInBytes*/) { return 0; } diff --git a/Swift/QtUI/QtChatView.h b/Swift/QtUI/QtChatView.h index 61c6f24..52125b7 100644 --- a/Swift/QtUI/QtChatView.h +++ b/Swift/QtUI/QtChatView.h @@ -39,7 +39,7 @@ namespace Swift { virtual void addErrorMessage(const ChatWindow::ChatMessage& message) = 0; virtual void replaceMessage(const ChatWindow::ChatMessage& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight) = 0; virtual void replaceWithAction(const ChatWindow::ChatMessage& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight) = 0; - virtual void replaceLastMessage(const ChatWindow::ChatMessage& message) = 0; + virtual void replaceLastMessage(const ChatWindow::ChatMessage& message, const ChatWindow::TimestampBehaviour /*timestampBehaviour*/) = 0; virtual void setAckState(const std::string& id, ChatWindow::AckState state) = 0; virtual std::string addFileTransfer(const std::string& senderName, bool senderIsSelf, const std::string& filename, const boost::uintmax_t sizeInBytes) = 0; diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index f0d2038..74ff109 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -791,8 +791,8 @@ void QtChatWindow::setWhiteboardSessionStatus(std::string id, const ChatWindow:: messageLog_->setWhiteboardSessionStatus(id, state); } -void QtChatWindow::replaceLastMessage(const ChatMessage& message) { - messageLog_->replaceLastMessage(message); +void QtChatWindow::replaceLastMessage(const ChatMessage& message, const TimestampBehaviour timestampBehaviour) { + messageLog_->replaceLastMessage(message, timestampBehaviour); } void QtChatWindow::setAckState(const std::string& id, AckState state) { diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index 95edcd0..b8e3c6a 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -112,7 +112,7 @@ namespace Swift { void setRosterModel(Roster* roster); void setTabComplete(TabComplete* completer); int getCount(); - void replaceLastMessage(const ChatMessage& message); + void replaceLastMessage(const ChatMessage& message, const TimestampBehaviour timestampBehaviour); void setAckState(const std::string& id, AckState state); // message receipts diff --git a/Swift/QtUI/QtPlainChatView.cpp b/Swift/QtUI/QtPlainChatView.cpp index ee76438..23bf0af 100644 --- a/Swift/QtUI/QtPlainChatView.cpp +++ b/Swift/QtUI/QtPlainChatView.cpp @@ -154,7 +154,7 @@ void QtPlainChatView::replaceWithAction(const ChatWindow::ChatMessage& message, log_->append(text); } -void QtPlainChatView::replaceLastMessage(const ChatWindow::ChatMessage& message) +void QtPlainChatView::replaceLastMessage(const ChatWindow::ChatMessage& message, const ChatWindow::TimestampBehaviour /*timestampBehaviour*/) { QString text = "<p>The last message was corrected to:<br/>"; text += chatMessageToString(message); diff --git a/Swift/QtUI/QtPlainChatView.h b/Swift/QtUI/QtPlainChatView.h index cf65fb3..06613f9 100644 --- a/Swift/QtUI/QtPlainChatView.h +++ b/Swift/QtUI/QtPlainChatView.h @@ -46,7 +46,7 @@ namespace Swift { virtual void replaceMessage(const ChatWindow::ChatMessage& /*message*/, const std::string& /*id*/, const boost::posix_time::ptime& /*time*/, const HighlightAction& /*highlight*/); virtual void replaceWithAction(const ChatWindow::ChatMessage& /*message*/, const std::string& /*id*/, const boost::posix_time::ptime& /*time*/, const HighlightAction& /*highlight*/); - virtual void replaceLastMessage(const ChatWindow::ChatMessage& /*message*/); + virtual void replaceLastMessage(const ChatWindow::ChatMessage& /*message*/, const ChatWindow::TimestampBehaviour /*timestampBehaviour*/); virtual void setAckState(const std::string& /*id*/, ChatWindow::AckState /*state*/); virtual std::string addFileTransfer(const std::string& /*senderName*/, bool /*senderIsSelf*/, const std::string& /*filename*/, const boost::uintmax_t /*sizeInBytes*/); diff --git a/Swift/QtUI/QtWebKitChatView.cpp b/Swift/QtUI/QtWebKitChatView.cpp index 3f021e9..23bc099 100644 --- a/Swift/QtUI/QtWebKitChatView.cpp +++ b/Swift/QtUI/QtWebKitChatView.cpp @@ -214,7 +214,7 @@ void QtWebKitChatView::addLastSeenLine() { newInsertPoint_.prependOutside(lineSeparator_); } -void QtWebKitChatView::replaceLastMessage(const QString& newMessage) { +void QtWebKitChatView::replaceLastMessage(const QString& newMessage, const ChatWindow::TimestampBehaviour timestampBehaviour) { assert(viewReady_); rememberScrolledToBottom(); assert(!lastElement_.isNull()); @@ -222,11 +222,16 @@ void QtWebKitChatView::replaceLastMessage(const QString& newMessage) { assert(!replace.isNull()); QString old = lastElement_.toOuterXml(); replace.setInnerXml(ChatSnippet::escape(newMessage)); + if (timestampBehaviour == ChatWindow::UpdateTimestamp) { + replace = lastElement_.findFirst("span.swift_time"); + assert(!replace.isNull()); + replace.setInnerXml(ChatSnippet::timeToEscapedString(QDateTime::currentDateTime())); + } } void QtWebKitChatView::replaceLastMessage(const QString& newMessage, const QString& note) { rememberScrolledToBottom(); - replaceLastMessage(newMessage); + replaceLastMessage(newMessage, ChatWindow::KeepTimestamp); QWebElement replace = lastElement_.findFirst("span.swift_time"); assert(!replace.isNull()); replace.setInnerXml(ChatSnippet::escape(note)); @@ -840,8 +845,8 @@ void QtWebKitChatView::addPresenceMessage(const ChatWindow::ChatMessage& message previousMessageKind_ = PreviousMessageWasPresence; } -void QtWebKitChatView::replaceLastMessage(const ChatWindow::ChatMessage& message) { - replaceLastMessage(chatMessageToHTML(message)); +void QtWebKitChatView::replaceLastMessage(const ChatWindow::ChatMessage& message, const ChatWindow::TimestampBehaviour timestampBehaviour) { + replaceLastMessage(chatMessageToHTML(message), timestampBehaviour); } void QtWebKitChatView::addMUCInvitation(const std::string& senderName, const JID& jid, const std::string& reason, const std::string& password, bool direct, bool isImpromptu, bool isContinuation) { diff --git a/Swift/QtUI/QtWebKitChatView.h b/Swift/QtUI/QtWebKitChatView.h index bdb2a75..fb6e4da 100644 --- a/Swift/QtUI/QtWebKitChatView.h +++ b/Swift/QtUI/QtWebKitChatView.h @@ -61,7 +61,7 @@ namespace Swift { virtual void addErrorMessage(const ChatWindow::ChatMessage& message) SWIFTEN_OVERRIDE; virtual void replaceMessage(const ChatWindow::ChatMessage& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight) SWIFTEN_OVERRIDE; virtual void replaceWithAction(const ChatWindow::ChatMessage& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight) SWIFTEN_OVERRIDE; - void replaceLastMessage(const ChatWindow::ChatMessage& message); + void replaceLastMessage(const ChatWindow::ChatMessage& message, const ChatWindow::TimestampBehaviour timestampBehaviour); void setAckState(const std::string& id, ChatWindow::AckState state); virtual std::string addFileTransfer(const std::string& senderName, bool senderIsSelf, const std::string& filename, const boost::uintmax_t sizeInBytes) SWIFTEN_OVERRIDE; @@ -80,7 +80,7 @@ namespace Swift { void addLastSeenLine(); private: // previously public, now private - void replaceLastMessage(const QString& newMessage); + void replaceLastMessage(const QString& newMessage, const ChatWindow::TimestampBehaviour timestampBehaviour); void replaceLastMessage(const QString& newMessage, const QString& note); void replaceMessage(const QString& newMessage, const QString& id, const QDateTime& time); void rememberScrolledToBottom(); |