diff options
author | Sergey Borushevsky <sborushevsky@productengine.com> | 2009-10-29 20:26:56 +0200 |
---|---|---|
committer | Sergey Borushevsky <sborushevsky@productengine.com> | 2009-10-29 20:26:56 +0200 |
commit | e724fa0ab4c4675b94546f67bd4323704201f4a6 (patch) | |
tree | 5fcca2da8a7494c147b94221e845c73176715359 /indra/newview/llimview.cpp | |
parent | 7d64c6a226046d962bf5cd2b1e53df6fe33a730d (diff) |
Implemented major task EXT-1487 (Reimplement chat history persistence using LLSD serialization).
Moved loading of IM history from LLIMFloater and LLFloaterIMPanel to LLModel::LLIMSession.
Implemented disabling of saving logs if it's disabled in Preferences.
--HG--
branch : product-engine
Diffstat (limited to 'indra/newview/llimview.cpp')
-rw-r--r-- | indra/newview/llimview.cpp | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index cc848e519f..49fc9d8055 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -135,7 +135,6 @@ LLIMModel::LLIMModel() addNewMsgCallback(toast_callback); } - LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string& name, const EInstantMessage& type, const LLUUID& other_participant_id, const std::vector<LLUUID>& ids) : mSessionID(session_id), mName(name), @@ -179,6 +178,9 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string& mTextIMPossible = LLVoiceClient::getInstance()->isSessionTextIMPossible(mSessionID); mOtherParticipantIsAvatar = LLVoiceClient::getInstance()->isParticipantAvatar(mSessionID); } + + if ( gSavedPerAccountSettings.getBOOL("LogShowHistory") ) + LLLogChat::loadHistory(mName, &chatFromLogFile, (void *)this); } LLIMModel::LLIMSession::~LLIMSession() @@ -220,6 +222,34 @@ void LLIMModel::LLIMSession::sessionInitReplyReceived(const LLUUID& new_session_ } } +void LLIMModel::LLIMSession::addMessage(const std::string& from, const LLUUID& from_id, const std::string& utf8_text, const std::string& time) +{ + LLSD message; + message["from"] = from; + message["from_id"] = from_id; + message["message"] = utf8_text; + message["time"] = time; + message["index"] = (LLSD::Integer)mMsgs.size(); + + mMsgs.push_front(message); +} + +void LLIMModel::LLIMSession::chatFromLogFile(LLLogChat::ELogLineType type, const LLSD& msg, void* userdata) +{ + if (!userdata) return; + + LLIMSession* self = (LLIMSession*) userdata; + + if (type == LLLogChat::LOG_LINE) + { + self->addMessage("", LLSD(), msg["message"].asString(), ""); + } + else if (type == LLLogChat::LOG_LLSD) + { + self->addMessage(msg["from"].asString(), msg["from_id"].asUUID(), msg["message"].asString(), msg["time"].asString()); + } +} + LLIMModel::LLIMSession* LLIMModel::findIMSession(const LLUUID& session_id) const { return get_if_there(LLIMModel::instance().sSessionsMap, session_id, @@ -348,39 +378,25 @@ bool LLIMModel::addToHistory(const LLUUID& session_id, const std::string& from, return false; } - LLSD message; - message["from"] = from; - message["from_id"] = from_id; - message["message"] = utf8_text; - message["time"] = LLLogChat::timestamp(false); //might want to add date separately - message["index"] = (LLSD::Integer)session->mMsgs.size(); - - session->mMsgs.push_front(message); + session->addMessage(from, from_id, utf8_text, LLLogChat::timestamp(false)); //might want to add date separately return true; - } //*TODO rewrite chat history persistence using LLSD serialization (IB) -bool LLIMModel::logToFile(const LLUUID& session_id, const std::string& from, const std::string& utf8_text) +bool LLIMModel::logToFile(const LLUUID& session_id, const std::string& from, const LLUUID& from_id, const std::string& utf8_text) { S32 im_log_option = gSavedPerAccountSettings.getS32("IMLogOptions"); if (im_log_option != LOG_CHAT) { - std::string histstr; - if (gSavedPerAccountSettings.getBOOL("LogTimestamp")) - histstr = LLLogChat::timestamp(gSavedPerAccountSettings.getBOOL("LogTimestampDate")) + from + IM_SEPARATOR + utf8_text; - else - histstr = from + IM_SEPARATOR + utf8_text; - if(im_log_option == LOG_BOTH_TOGETHER) { - LLLogChat::saveHistory(std::string("chat"), histstr); + LLLogChat::saveHistory(std::string("chat"), from, from_id, utf8_text); return true; } else { - LLLogChat::saveHistory(LLIMModel::getInstance()->getName(session_id), histstr); + LLLogChat::saveHistory(LLIMModel::getInstance()->getName(session_id), from, from_id, utf8_text); return true; } } @@ -398,7 +414,7 @@ bool LLIMModel::addMessage(const LLUUID& session_id, const std::string& from, co } addToHistory(session_id, from, from_id, utf8_text); - if (log2file) logToFile(session_id, from, utf8_text); + if (log2file) logToFile(session_id, from, from_id, utf8_text); session->mNumUnread++; |