summaryrefslogtreecommitdiff
path: root/indra/newview/lllogchat.cpp
diff options
context:
space:
mode:
authorWolfpup Lowenhar <wolfpup67@earthlink.net>2010-10-26 20:02:07 -0400
committerWolfpup Lowenhar <wolfpup67@earthlink.net>2010-10-26 20:02:07 -0400
commit7c89e565b373803b64cabaac3695ac3e93469962 (patch)
treee2fed34d493ec3e9715de17de67e314fe7ef0eed /indra/newview/lllogchat.cpp
parent9abbb6c927d4f4131b0aefe6b847be0b44022c97 (diff)
This is the setting of the core file name date stamp code and settings files for
Chat, Group and IM Logs. --HG-- branch : storm-102
Diffstat (limited to 'indra/newview/lllogchat.cpp')
-rw-r--r--indra/newview/lllogchat.cpp62
1 files changed, 59 insertions, 3 deletions
diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp
index 8c70b1e973..0e557cba5d 100644
--- a/indra/newview/lllogchat.cpp
+++ b/indra/newview/lllogchat.cpp
@@ -182,9 +182,25 @@ private:
//static
std::string LLLogChat::makeLogFileName(std::string filename)
{
+ if( gSavedPerAccountSettings.getBOOL("LogFileNamewithDate") )
+ {
+ time_t now;
+ time(&now);
+ char dbuffer[20]; /* Flawfinder: ignore */
+ if (filename == "chat")
+ {
+ strftime(dbuffer, 20, "-%Y-%m-%d", localtime(&now));
+ }
+ else
+ {
+ strftime(dbuffer, 20, "-%Y-%m", localtime(&now));
+ }
+ filename += dbuffer;
+ }
filename = cleanFileName(filename);
filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_ACCOUNT_CHAT_LOGS,filename);
filename += ".txt";
+ LL_INFOS("") << "Current:" << filename << LL_ENDL;/* uncomment if you want to verify step, delete on commit */
return filename;
}
@@ -355,9 +371,21 @@ void LLLogChat::loadAllHistory(const std::string& file_name, std::list<LLSD>& me
return ;
}
- LLFILE* fptr = LLFile::fopen(makeLogFileName(file_name), "r"); /*Flawfinder: ignore*/
- if (!fptr) return; //No previous conversation with this name.
-
+ LLFILE* fptr = LLFile::fopen(makeLogFileName(file_name), "r");/*Flawfinder: ignore*/
+ // LL_INFOS("") << "Current:" << file_name << LL_ENDL;/* uncomment if you want to verify step, delete on commit */
+ if (!fptr)
+ {
+ fptr = LLFile::fopen(oldLogFileName(file_name), "r");/*Flawfinder: ignore*/
+ //LL_INFOS("") << "Old :" << file_name << LL_ENDL;/* uncomment if you want to verify step, delete on commit */
+ if (!fptr)
+ {
+ fptr =LLFile::fopen(ndsLogFileName(file_name), "r");/*Flawfinder:ignore*/
+ //LL_INFOS("") << "Orginal:" << file_name << LL_ENDL;/* uncomment if you want to verify step, delete on commit */
+ if (!fptr) return; //No previous conversation with this name.
+ }
+ }
+
+ LL_INFOS("") << "Reading:" << file_name << LL_ENDL;
char buffer[LOG_RECALL_SIZE]; /*Flawfinder: ignore*/
char *bptr;
S32 len;
@@ -544,3 +572,31 @@ bool LLChatLogParser::parse(std::string& raw, LLSD& im)
im[IM_TEXT] = name_and_text[IDX_TEXT];
return true; //parsed name and message text, maybe have a timestamp too
}
+std::string LLLogChat::oldLogFileName(std::string filename)
+{
+ time_t now;
+ time_t yesterday = time(&now) - 86400;
+ char dbuffer[20]; /* Flawfinder: ignore */
+ if (filename == "chat")
+ {
+ strftime(dbuffer, 20, "-%Y-%m-%d", localtime(&yesterday));
+ }
+ else
+ {
+ strftime(dbuffer, 20, "-%Y-%m", localtime(&yesterday));
+ }
+ filename += dbuffer;
+ filename = cleanFileName(filename);
+ filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_ACCOUNT_CHAT_LOGS,filename);
+ filename += ".txt";
+ //LL_INFOS("") << "Old :" << filename << LL_ENDL;/* uncomment if you want to verify step, delete on commit */
+ return filename;
+}
+std::string LLLogChat::ndsLogFileName(std::string filename)
+{
+ filename = cleanFileName(filename);
+ filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_ACCOUNT_CHAT_LOGS,filename);
+ filename += ".txt";
+ //LL_INFOS("") << "Original:" << filename << LL_ENDL;/* uncomment if you want to verify step, delete on commit */
+ return filename;
+}