diff options
author | Catalin Badea <catalin.badea392@gmail.com> | 2012-08-02 15:01:55 (GMT) |
---|---|---|
committer | Cătălin Badea <catalin.badea392@gmail.com> | 2012-08-11 15:59:13 (GMT) |
commit | 2316553cb5a191e0e8b098bb5b39fba0d9e37b13 (patch) | |
tree | e3f905491ffa65ff83c069a792d5b851d10b2134 /Swift/Controllers/Chat | |
parent | f3401e17bf241734414a3ff84e94ee64b882bcbc (diff) | |
download | swift-contrib-2316553cb5a191e0e8b098bb5b39fba0d9e37b13.zip swift-contrib-2316553cb5a191e0e8b098bb5b39fba0d9e37b13.tar.bz2 |
use local db when joining a muc.
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r-- | Swift/Controllers/Chat/MUCController.cpp | 20 | ||||
-rw-r--r-- | Swift/Controllers/Chat/MUCController.h | 1 |
2 files changed, 18 insertions, 3 deletions
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index bdc9b20..68be032 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -196,10 +196,10 @@ void MUCController::rejoin() { } //FIXME: check for received activity if (lastActivity_ == boost::posix_time::not_a_date_time) { - muc_->joinAs(nick_); - } else { - muc_->joinWithContextSince(nick_, lastActivity_); + lastActivity_ = historyController_->getLastTimeStampFromMUC(selfJID_, toJID_); } + + muc_->joinWithContextSince(nick_, lastActivity_); } } @@ -275,6 +275,9 @@ void MUCController::handleJoinComplete(const std::string& nick) { std::string joinMessage = str(format(QT_TRANSLATE_NOOP("", "You have entered room %1% as %2%.")) % toJID_.toString() % nick); nick_ = nick; chatWindow_->addSystemMessage(joinMessage); + + addRecentLogs(); + clearPresenceQueue(); shouldJoinOnReconnect_ = true; setEnabled(true); @@ -788,4 +791,15 @@ void MUCController::logMessage(const std::string& message, const JID& fromJID, c } } +void MUCController::addRecentLogs() { + std::vector<HistoryMessage> messages = historyController_->getMUCContext(selfJID_, toJID_, lastActivity_); + + foreach (const HistoryMessage& message, messages) { + bool senderIsSelf = nick_ == message.getFromJID().getResource(); + + // the chatWindow uses utc timestamps + addMessage(message.getMessage(), senderDisplayNameFromMessage(message.getFromJID()), senderIsSelf, boost::shared_ptr<SecurityLabel>(new SecurityLabel()), std::string(avatarManager_->getAvatarPath(message.getFromJID()).string()), message.getTime() - boost::posix_time::hours(message.getOffset())); + } +} + } diff --git a/Swift/Controllers/Chat/MUCController.h b/Swift/Controllers/Chat/MUCController.h index 0c6cfa4..0ade758 100644 --- a/Swift/Controllers/Chat/MUCController.h +++ b/Swift/Controllers/Chat/MUCController.h @@ -106,6 +106,7 @@ namespace Swift { void handleChangeAffiliationsRequest(const std::vector<std::pair<MUCOccupant::Affiliation, JID> >& changes); void handleInviteToMUCWindowDismissed(); void handleInviteToMUCWindowCompleted(); + void addRecentLogs(); private: MUC::ref muc_; |