diff options
author | Paul ProductEngine <pguslisty@productengine.com> | 2012-09-07 21:35:08 +0300 |
---|---|---|
committer | Paul ProductEngine <pguslisty@productengine.com> | 2012-09-07 21:35:08 +0300 |
commit | 42dbf23dc56e0ab6842dd14b5701ffdb359f8bb6 (patch) | |
tree | e03b384f64fbad38650d2a601fab91ee7dfee20b | |
parent | 3cf624b371eace5ec382796d7bd811d181d5e877 (diff) |
CHUI-325 FIXED (Cap conversation log to 30 days, purge older data on login)
- Remove conversations older than 30 days from call log
-rw-r--r-- | indra/newview/llconversationlog.cpp | 22 | ||||
-rw-r--r-- | indra/newview/llconversationlog.h | 2 |
2 files changed, 24 insertions, 0 deletions
diff --git a/indra/newview/llconversationlog.cpp b/indra/newview/llconversationlog.cpp index e80a709203..cc02e18698 100644 --- a/indra/newview/llconversationlog.cpp +++ b/indra/newview/llconversationlog.cpp @@ -30,6 +30,8 @@ #include "llconversationlog.h" #include "lltrans.h" +const int CONVERSATION_LIFETIME = 30; // lifetime of LLConversation is 30 days by spec + struct Conversation_params { Conversation_params(time_t time) @@ -139,6 +141,14 @@ const std::string LLConversation::createTimestamp(const time_t& utc_time) return timeStr; } +bool LLConversation::isOlderThan(U32 days) const +{ + time_t now = time_corrected(); + U32 age = (U32)((now - mTime) / SEC_PER_DAY); // age of conversation in days + + return age > days; +} + void LLConversation::setListenIMFloaterOpened() { LLIMFloater* floater = LLIMFloater::findInstance(mSessionID); @@ -394,10 +404,22 @@ bool LLConversationLog::loadFromFile(const std::string& filename) params.mHistoryFileName = std::string(history_file_name); LLConversation conversation(params); + + // CHUI-325 + // The conversation log should be capped to the last 30 days. Conversations with the last utterance + // being over 30 days old should be purged from the conversation log text file on login. + if (conversation.isOlderThan(CONVERSATION_LIFETIME)) + { + continue; + } + mConversations.push_back(conversation); } fclose(fp); + LLFile::remove(filename); + cache(); + notifyObservers(); return true; } diff --git a/indra/newview/llconversationlog.h b/indra/newview/llconversationlog.h index 0d7f0080e5..16be37d67a 100644 --- a/indra/newview/llconversationlog.h +++ b/indra/newview/llconversationlog.h @@ -64,6 +64,8 @@ public: void setIsPast (bool is_past) { mIsConversationPast = is_past; } void setConverstionName(std::string conv_name) { mConversationName = conv_name; } + bool isOlderThan(U32 days) const; + /* * Resets flag of unread offline message to false when im floater with this conversation is opened. */ |