From d6ea42984553b7adb6f26cf2ed094d32e36814d2 Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 25 May 2010 11:40:29 -0700 Subject: DEV-50013 Display names load at startup in local chat/IM history Had to change the chat log file format to include agent_id. Code will load viewer 2.0 logs, but viewer 2.0 will just discard data from 2.1 logs, which seems OK. Reviewed with Leyla. --- indra/newview/lllogchat.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'indra/newview/lllogchat.cpp') diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index be8b2363ad..1d348834fe 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -426,6 +426,12 @@ void LLChatLogFormatter::format(const LLSD& im, std::ostream& ostr) const return; } + if (im[IM_FROM_ID].isDefined()) + { + LLUUID from_id = im[IM_FROM_ID].asUUID(); + ostr << '{' << from_id.asString() << '}'; + } + if (im[IM_TIME].isDefined()) { std::string timestamp = im[IM_TIME].asString(); @@ -456,15 +462,32 @@ void LLChatLogFormatter::format(const LLSD& im, std::ostream& ostr) const } } -bool LLChatLogParser::parse(std::string& raw, LLSD& im) +bool LLChatLogParser::parse(const std::string& raw, LLSD& im) { if (!raw.length()) return false; im = LLSD::emptyMap(); + // In Viewer 2.1 we added UUID to chat/IM logging so we can look up + // display names + std::string line = raw; + if (raw[0] == '{') + { + const S32 UUID_LEN = 36; + size_t pos = line.find_first_of('}'); + // If it matches, pos will be 37 + if (pos != line.npos && pos > UUID_LEN) + { + std::string uuid_string = line.substr(1, UUID_LEN); + LLUUID from_id(uuid_string); + im[IM_FROM_ID] = from_id; + line = line.substr(pos + 1); + } + } + //matching a timestamp boost::match_results matches; - if (!boost::regex_match(raw, matches, TIMESTAMP_AND_STUFF)) return false; + if (!boost::regex_match(line, matches, TIMESTAMP_AND_STUFF)) return false; bool has_timestamp = matches[IDX_TIMESTAMP].matched; if (has_timestamp) -- cgit v1.2.3 From b34eee98d1cd542777a9fc28b1e1d2e3a0de24e5 Mon Sep 17 00:00:00 2001 From: James Cook Date: Wed, 2 Jun 2010 15:21:46 -0700 Subject: DEV-50451 Fix names in local chat history loading, again Switch to new serialization format, change filename so old viewers don't get confused if the user switches back. Reviewed with Richard --- indra/newview/lllogchat.cpp | 179 +++++++++++--------------------------------- 1 file changed, 43 insertions(+), 136 deletions(-) (limited to 'indra/newview/lllogchat.cpp') diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index 1d348834fe..d4ebdd768b 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -32,13 +32,18 @@ #include "llviewerprecompiledheaders.h" +#include "lllogchat.h" + +// viewer includes #include "llagent.h" #include "llagentui.h" -#include "lllogchat.h" #include "lltrans.h" #include "llviewercontrol.h" +// library includes +#include "llchat.h" #include "llinstantmessage.h" +#include "llsdserialize.h" #include "llsingleton.h" // for LLSingleton #include @@ -62,12 +67,13 @@ const S32 LOG_RECALL_SIZE = 2048; -const static std::string IM_TIME("time"); -const static std::string IM_TEXT("message"); -const static std::string IM_FROM("from"); -const static std::string IM_FROM_ID("from_id"); -const static std::string IM_SEPARATOR(": "); +const std::string IM_TIME("time"); +const std::string IM_TEXT("message"); +const std::string IM_FROM("from"); +const std::string IM_FROM_ID("from_id"); +const std::string IM_SOURCE_TYPE("source_type"); +const static std::string IM_SEPARATOR(": "); const static std::string NEW_LINE("\n"); const static std::string NEW_LINE_SPACE_PREFIX("\n "); const static std::string TWO_SPACES(" "); @@ -190,7 +196,8 @@ std::string LLLogChat::makeLogFileName(std::string filename) { filename = cleanFileName(filename); filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_ACCOUNT_CHAT_LOGS,filename); - filename += ".txt"; + // new files are llsd notation format + filename += ".llsd"; return filename; } @@ -239,6 +246,18 @@ void LLLogChat::saveHistory(const std::string& filename, const std::string& from, const LLUUID& from_id, const std::string& line) +{ + LLChat chat; + chat.mText = line; + chat.mFromName = from; + chat.mFromID = from_id; + // default to being from an agent + chat.mSourceType = CHAT_SOURCE_AGENT; + saveHistory(filename, chat); +} + +//static +void LLLogChat::saveHistory(const std::string& filename, const LLChat& chat) { std::string tmp_filename = filename; LLStringUtil::trim(tmp_filename); @@ -260,89 +279,27 @@ void LLLogChat::saveHistory(const std::string& filename, LLSD item; if (gSavedPerAccountSettings.getBOOL("LogTimestamp")) - item["time"] = LLLogChat::timestamp(gSavedPerAccountSettings.getBOOL("LogTimestampDate")); + item[IM_TIME] = LLLogChat::timestamp(gSavedPerAccountSettings.getBOOL("LogTimestampDate")); - item["from_id"] = from_id; - item["message"] = line; + item[IM_FROM_ID] = chat.mFromID; + item[IM_TEXT] = chat.mText; + item[IM_SOURCE_TYPE] = chat.mSourceType; //adding "Second Life:" for all system messages to make chat log history parsing more reliable - if (from.empty() && from_id.isNull()) + if (chat.mFromName.empty() && chat.mFromID.isNull()) { - item["from"] = SYSTEM_FROM; + item[IM_FROM] = SYSTEM_FROM; } else { - item["from"] = from; + item[IM_FROM] = chat.mFromName; } - file << LLChatLogFormatter(item) << std::endl; + file << LLSDOStreamer(item) << std::endl; file.close(); } -void LLLogChat::loadHistory(const std::string& filename, void (*callback)(ELogLineType, const LLSD&, void*), void* userdata) -{ - if(!filename.size()) - { - llwarns << "Filename is Empty!" << llendl; - return ; - } - - LLFILE* fptr = LLFile::fopen(makeLogFileName(filename), "r"); /*Flawfinder: ignore*/ - if (!fptr) - { - callback(LOG_EMPTY, LLSD(), userdata); - return; //No previous conversation with this name. - } - else - { - char buffer[LOG_RECALL_SIZE]; /*Flawfinder: ignore*/ - char *bptr; - S32 len; - bool firstline=TRUE; - - if ( fseek(fptr, (LOG_RECALL_SIZE - 1) * -1 , SEEK_END) ) - { //File is smaller than recall size. Get it all. - firstline = FALSE; - if ( fseek(fptr, 0, SEEK_SET) ) - { - fclose(fptr); - return; - } - } - - while ( fgets(buffer, LOG_RECALL_SIZE, fptr) && !feof(fptr) ) - { - len = strlen(buffer) - 1; /*Flawfinder: ignore*/ - for ( bptr = (buffer + len); (*bptr == '\n' || *bptr == '\r') && bptr>buffer; bptr--) *bptr='\0'; - - if (!firstline) - { - LLSD item; - std::string line(buffer); - std::istringstream iss(line); - - if (!LLChatLogParser::parse(line, item)) - { - item["message"] = line; - callback(LOG_LINE, item, userdata); - } - else - { - callback(LOG_LLSD, item, userdata); - } - } - else - { - firstline = FALSE; - } - } - callback(LOG_END, LLSD(), userdata); - - fclose(fptr); - } -} - void append_to_last_message(std::list& messages, const std::string& line) { if (!messages.size()) return; @@ -352,6 +309,7 @@ void append_to_last_message(std::list& messages, const std::string& line) messages.back()[IM_TEXT] = im_text; } +// static void LLLogChat::loadAllHistory(const std::string& file_name, std::list& messages) { if (file_name.empty()) @@ -415,53 +373,7 @@ void LLLogChat::loadAllHistory(const std::string& file_name, std::list& me fclose(fptr); } -//*TODO mark object's names in a special way so that they will be distinguishable form avatar name -//which are more strict by its nature (only firstname and secondname) -//Example, an object's name can be writen like "Object " -void LLChatLogFormatter::format(const LLSD& im, std::ostream& ostr) const -{ - if (!im.isMap()) - { - llwarning("invalid LLSD type of an instant message", 0); - return; - } - - if (im[IM_FROM_ID].isDefined()) - { - LLUUID from_id = im[IM_FROM_ID].asUUID(); - ostr << '{' << from_id.asString() << '}'; - } - - if (im[IM_TIME].isDefined()) - { - std::string timestamp = im[IM_TIME].asString(); - boost::trim(timestamp); - ostr << '[' << timestamp << ']' << TWO_SPACES; - } - - //*TODO mark object's names in a special way so that they will be distinguishable form avatar name - //which are more strict by its nature (only firstname and secondname) - //Example, an object's name can be writen like "Object " - if (im[IM_FROM].isDefined()) - { - std::string from = im[IM_FROM].asString(); - boost::trim(from); - if (from.size()) - { - ostr << from << IM_SEPARATOR; - } - } - - if (im[IM_TEXT].isDefined()) - { - std::string im_text = im[IM_TEXT].asString(); - - //multilined text will be saved with prepended spaces - boost::replace_all(im_text, NEW_LINE, NEW_LINE_SPACE_PREFIX); - ostr << im_text; - } -} - +// static bool LLChatLogParser::parse(const std::string& raw, LLSD& im) { if (!raw.length()) return false; @@ -470,24 +382,19 @@ bool LLChatLogParser::parse(const std::string& raw, LLSD& im) // In Viewer 2.1 we added UUID to chat/IM logging so we can look up // display names - std::string line = raw; if (raw[0] == '{') { - const S32 UUID_LEN = 36; - size_t pos = line.find_first_of('}'); - // If it matches, pos will be 37 - if (pos != line.npos && pos > UUID_LEN) - { - std::string uuid_string = line.substr(1, UUID_LEN); - LLUUID from_id(uuid_string); - im[IM_FROM_ID] = from_id; - line = line.substr(pos + 1); - } + // ...this is a viewer 2.1, new-style LLSD notation format log + std::istringstream raw_stream(raw); + LLPointer parser = new LLSDNotationParser(); + S32 count = parser->parse(raw_stream, im, raw.length()); + // expect several map items per parsed line + return (count != LLSDParser::PARSE_FAILURE); } //matching a timestamp boost::match_results matches; - if (!boost::regex_match(line, matches, TIMESTAMP_AND_STUFF)) return false; + if (!boost::regex_match(raw, matches, TIMESTAMP_AND_STUFF)) return false; bool has_timestamp = matches[IDX_TIMESTAMP].matched; if (has_timestamp) -- cgit v1.2.3 From cb5d8d1a9295076327f23e5f6d6c91fd0d4580ea Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Fri, 22 Oct 2010 17:41:06 -0700 Subject: DN-181 Chat & IM logs saved in unreadable .llsd instead of .txt --- indra/newview/lllogchat.cpp | 157 ++++++++++++++++++++++++++++++++------------ 1 file changed, 114 insertions(+), 43 deletions(-) (limited to 'indra/newview/lllogchat.cpp') diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index c8fd1e1d9a..8c70b1e973 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -26,18 +26,13 @@ #include "llviewerprecompiledheaders.h" -#include "lllogchat.h" - -// viewer includes #include "llagent.h" #include "llagentui.h" +#include "lllogchat.h" #include "lltrans.h" #include "llviewercontrol.h" -// library includes -#include "llchat.h" #include "llinstantmessage.h" -#include "llsdserialize.h" #include "llsingleton.h" // for LLSingleton #include @@ -65,7 +60,6 @@ const std::string IM_TIME("time"); const std::string IM_TEXT("message"); const std::string IM_FROM("from"); const std::string IM_FROM_ID("from_id"); -const std::string IM_SOURCE_TYPE("source_type"); const static std::string IM_SEPARATOR(": "); const static std::string NEW_LINE("\n"); @@ -93,7 +87,7 @@ const static boost::regex TIMESTAMP_AND_STUFF("^(\\[\\d{4}/\\d{1,2}/\\d{1,2}\\s+ * Regular expression suitable to match names like * "You", "Second Life", "Igor ProductEngine", "Object", "Mega House" */ -const static boost::regex NAME_AND_TEXT("(You:|Second Life:|[^\\s:]+\\s*[:]{1}|\\S+\\s+[^\\s:]+[:]{1})?(\\s*)(.*)"); +const static boost::regex NAME_AND_TEXT("([^:]+[:]{1})?(\\s*)(.*)"); //is used to parse complex object names like "Xstreet SL Terminal v2.2.5 st" const static std::string NAME_TEXT_DIVIDER(": "); @@ -190,8 +184,7 @@ std::string LLLogChat::makeLogFileName(std::string filename) { filename = cleanFileName(filename); filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_ACCOUNT_CHAT_LOGS,filename); - // new files are llsd notation format - filename += ".llsd"; + filename += ".txt"; return filename; } @@ -240,18 +233,6 @@ void LLLogChat::saveHistory(const std::string& filename, const std::string& from, const LLUUID& from_id, const std::string& line) -{ - LLChat chat; - chat.mText = line; - chat.mFromName = from; - chat.mFromID = from_id; - // default to being from an agent - chat.mSourceType = CHAT_SOURCE_AGENT; - saveHistory(filename, chat); -} - -//static -void LLLogChat::saveHistory(const std::string& filename, const LLChat& chat) { std::string tmp_filename = filename; LLStringUtil::trim(tmp_filename); @@ -273,27 +254,89 @@ void LLLogChat::saveHistory(const std::string& filename, const LLChat& chat) LLSD item; if (gSavedPerAccountSettings.getBOOL("LogTimestamp")) - item[IM_TIME] = LLLogChat::timestamp(gSavedPerAccountSettings.getBOOL("LogTimestampDate")); + item["time"] = LLLogChat::timestamp(gSavedPerAccountSettings.getBOOL("LogTimestampDate")); - item[IM_FROM_ID] = chat.mFromID; - item[IM_TEXT] = chat.mText; - item[IM_SOURCE_TYPE] = chat.mSourceType; + item["from_id"] = from_id; + item["message"] = line; //adding "Second Life:" for all system messages to make chat log history parsing more reliable - if (chat.mFromName.empty() && chat.mFromID.isNull()) + if (from.empty() && from_id.isNull()) { - item[IM_FROM] = SYSTEM_FROM; + item["from"] = SYSTEM_FROM; } else { - item[IM_FROM] = chat.mFromName; + item["from"] = from; } - file << LLSDOStreamer(item) << std::endl; + file << LLChatLogFormatter(item) << std::endl; file.close(); } +void LLLogChat::loadHistory(const std::string& filename, void (*callback)(ELogLineType, const LLSD&, void*), void* userdata) +{ + if(!filename.size()) + { + llwarns << "Filename is Empty!" << llendl; + return ; + } + + LLFILE* fptr = LLFile::fopen(makeLogFileName(filename), "r"); /*Flawfinder: ignore*/ + if (!fptr) + { + callback(LOG_EMPTY, LLSD(), userdata); + return; //No previous conversation with this name. + } + else + { + char buffer[LOG_RECALL_SIZE]; /*Flawfinder: ignore*/ + char *bptr; + S32 len; + bool firstline=TRUE; + + if ( fseek(fptr, (LOG_RECALL_SIZE - 1) * -1 , SEEK_END) ) + { //File is smaller than recall size. Get it all. + firstline = FALSE; + if ( fseek(fptr, 0, SEEK_SET) ) + { + fclose(fptr); + return; + } + } + + while ( fgets(buffer, LOG_RECALL_SIZE, fptr) && !feof(fptr) ) + { + len = strlen(buffer) - 1; /*Flawfinder: ignore*/ + for ( bptr = (buffer + len); (*bptr == '\n' || *bptr == '\r') && bptr>buffer; bptr--) *bptr='\0'; + + if (!firstline) + { + LLSD item; + std::string line(buffer); + std::istringstream iss(line); + + if (!LLChatLogParser::parse(line, item)) + { + item["message"] = line; + callback(LOG_LINE, item, userdata); + } + else + { + callback(LOG_LLSD, item, userdata); + } + } + else + { + firstline = FALSE; + } + } + callback(LOG_END, LLSD(), userdata); + + fclose(fptr); + } +} + void append_to_last_message(std::list& messages, const std::string& line) { if (!messages.size()) return; @@ -367,24 +410,52 @@ void LLLogChat::loadAllHistory(const std::string& file_name, std::list& me fclose(fptr); } -// static -bool LLChatLogParser::parse(const std::string& raw, LLSD& im) +//*TODO mark object's names in a special way so that they will be distinguishable form avatar name +//which are more strict by its nature (only firstname and secondname) +//Example, an object's name can be writen like "Object " +void LLChatLogFormatter::format(const LLSD& im, std::ostream& ostr) const { - if (!raw.length()) return false; + if (!im.isMap()) + { + llwarning("invalid LLSD type of an instant message", 0); + return; + } + + if (im[IM_TIME].isDefined()) +{ + std::string timestamp = im[IM_TIME].asString(); + boost::trim(timestamp); + ostr << '[' << timestamp << ']' << TWO_SPACES; + } - im = LLSD::emptyMap(); + //*TODO mark object's names in a special way so that they will be distinguishable form avatar name + //which are more strict by its nature (only firstname and secondname) + //Example, an object's name can be writen like "Object " + if (im[IM_FROM].isDefined()) + { + std::string from = im[IM_FROM].asString(); + boost::trim(from); + if (from.size()) + { + ostr << from << IM_SEPARATOR; + } + } - // In Viewer 2.1 we added UUID to chat/IM logging so we can look up - // display names - if (raw[0] == '{') + if (im[IM_TEXT].isDefined()) { - // ...this is a viewer 2.1, new-style LLSD notation format log - std::istringstream raw_stream(raw); - LLPointer parser = new LLSDNotationParser(); - S32 count = parser->parse(raw_stream, im, raw.length()); - // expect several map items per parsed line - return (count != LLSDParser::PARSE_FAILURE); + std::string im_text = im[IM_TEXT].asString(); + + //multilined text will be saved with prepended spaces + boost::replace_all(im_text, NEW_LINE, NEW_LINE_SPACE_PREFIX); + ostr << im_text; } + } + +bool LLChatLogParser::parse(std::string& raw, LLSD& im) +{ + if (!raw.length()) return false; + + im = LLSD::emptyMap(); //matching a timestamp boost::match_results matches; -- cgit v1.2.3 From 7c89e565b373803b64cabaac3695ac3e93469962 Mon Sep 17 00:00:00 2001 From: Wolfpup Lowenhar Date: Tue, 26 Oct 2010 20:02:07 -0400 Subject: 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 --- indra/newview/lllogchat.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-) (limited to 'indra/newview/lllogchat.cpp') 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& 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; +} -- cgit v1.2.3 From 669cf170ceae2609202fb948d388b7492f8eb90a Mon Sep 17 00:00:00 2001 From: Wolfpup Lowenhar Date: Mon, 8 Nov 2010 09:31:35 -0500 Subject: STORM-102: STORM-143: Refactored the STORM-103 code to pull the proper plain test log no matter when it was generated or if it has the date stamp in the name of the log or not. --HG-- branch : storm-102 --- indra/newview/lllogchat.cpp | 67 ++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 35 deletions(-) (limited to 'indra/newview/lllogchat.cpp') diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index 0e557cba5d..4f80472330 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -200,7 +200,7 @@ std::string LLLogChat::makeLogFileName(std::string filename) 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 */ + //LL_INFOS("") << "Current:" << filename << LL_ENDL;/* uncomment if you want to verify step, delete on commit */ return filename; } @@ -370,22 +370,19 @@ void LLLogChat::loadAllHistory(const std::string& file_name, std::list& me llwarns << "Session name is Empty!" << llendl; return ; } - + LL_INFOS("") << "Loading:" << file_name << LL_ENDL;/* uncomment if you want to verify step, delete on commit */ + LL_INFOS("") << "Current:" << makeLogFileName(file_name) << LL_ENDL;/* uncomment if you want to verify step, delete on commit */ 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. + if (!fptr) return; //No previous conversation with this name. } } - LL_INFOS("") << "Reading:" << file_name << LL_ENDL; + //LL_INFOS("") << "Reading:" << file_name << LL_ENDL; char buffer[LOG_RECALL_SIZE]; /*Flawfinder: ignore*/ char *bptr; S32 len; @@ -572,31 +569,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; +std::string LLLogChat::oldLogFileName(std::string filename) +{ + std::string scanResult; + std::string directory = gDirUtilp->getPerAccountChatLogsDir();/* get Users log directory */ + directory += gDirUtilp->getDirDelimiter();/* add final OS dependent delimiter */ + std::string pattern = (cleanFileName(filename)+(( filename == "chat" ) ? "-???\?-?\?-??.txt" : "-???\?-??.txt"));/* create search pattern*/ + LL_INFOS("") << "Checking:" << directory << " for " << pattern << LL_ENDL;/* uncomment if you want to verify step, delete on commit */ + std::vector allfiles; + + while (gDirUtilp->getNextFileInDir(directory, pattern, scanResult)) + { + //LL_INFOS("") << "Found :" << scanResult << LL_ENDL; + allfiles.push_back(scanResult); + } + + if (allfiles.size() == 0) // if no result from date search, return generic filename + { + scanResult = directory + filename + ".txt"; + } + else + { + std::sort(allfiles.begin(), allfiles.end()); + scanResult = directory + allfiles.back(); + // thisfile is now the most recent version of the file. + } + LL_INFOS("") << "Reading:" << scanResult << LL_ENDL; + return scanResult; } -- cgit v1.2.3 From 4077e6bb52f73a3ccd7f560788fc2fda21d7d9e7 Mon Sep 17 00:00:00 2001 From: Wolfpup Lowenhar Date: Thu, 11 Nov 2010 22:50:14 -0500 Subject: STORM-102 : STORM-143 :Made needed changes to code to improve searching for previous logs and also changed the name used for P2P IM log file names. The latter change is going to temporarely break personal content for those that are saving conversation logs as P2P IM logs will now be useinf the user name and not the legacy name. --- indra/newview/lllogchat.cpp | 53 +++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'indra/newview/lllogchat.cpp') diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index 4f80472330..2fb5ba82ba 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -206,7 +206,7 @@ std::string LLLogChat::makeLogFileName(std::string filename) std::string LLLogChat::cleanFileName(std::string filename) { - std::string invalidChars = "\"\'\\/?*:<>|"; + std::string invalidChars = "\"\'\\/?*:.<>|"; std::string::size_type position = filename.find_first_of(invalidChars); while (position != filename.npos) { @@ -370,8 +370,8 @@ void LLLogChat::loadAllHistory(const std::string& file_name, std::list& me llwarns << "Session name is Empty!" << llendl; return ; } - LL_INFOS("") << "Loading:" << file_name << LL_ENDL;/* uncomment if you want to verify step, delete on commit */ - LL_INFOS("") << "Current:" << makeLogFileName(file_name) << LL_ENDL;/* uncomment if you want to verify step, delete on commit */ + //LL_INFOS("") << "Loading:" << file_name << LL_ENDL;/* uncomment if you want to verify step, delete on commit */ + //LL_INFOS("") << "Current:" << makeLogFileName(file_name) << LL_ENDL;/* uncomment if you want to verify step, delete on commit */ LLFILE* fptr = LLFile::fopen(makeLogFileName(file_name), "r");/*Flawfinder: ignore*/ if (!fptr) { @@ -569,31 +569,32 @@ 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) -{ +std::string LLLogChat::oldLogFileName(std::string filename) +{ std::string scanResult; std::string directory = gDirUtilp->getPerAccountChatLogsDir();/* get Users log directory */ directory += gDirUtilp->getDirDelimiter();/* add final OS dependent delimiter */ - std::string pattern = (cleanFileName(filename)+(( filename == "chat" ) ? "-???\?-?\?-??.txt" : "-???\?-??.txt"));/* create search pattern*/ - LL_INFOS("") << "Checking:" << directory << " for " << pattern << LL_ENDL;/* uncomment if you want to verify step, delete on commit */ - std::vector allfiles; - - while (gDirUtilp->getNextFileInDir(directory, pattern, scanResult)) + filename=cleanFileName(filename);/* lest make shure the file name has no invalad charecters befor making the pattern */ + std::string pattern = (filename+(( filename == "chat" ) ? "-???\?-?\?-??.txt" : "-???\?-??.txt"));/* create search pattern*/ + //LL_INFOS("") << "Checking:" << directory << " for " << pattern << LL_ENDL;/* uncomment if you want to verify step, delete on commit */ + std::vector allfiles; + + while (gDirUtilp->getNextFileInDir(directory, pattern, scanResult)) + { + //LL_INFOS("") << "Found :" << scanResult << LL_ENDL; + allfiles.push_back(scanResult); + } + + if (allfiles.size() == 0) // if no result from date search, return generic filename + { + scanResult = directory + filename + ".txt"; + } + else { - //LL_INFOS("") << "Found :" << scanResult << LL_ENDL; - allfiles.push_back(scanResult); - } - - if (allfiles.size() == 0) // if no result from date search, return generic filename - { - scanResult = directory + filename + ".txt"; - } - else - { - std::sort(allfiles.begin(), allfiles.end()); - scanResult = directory + allfiles.back(); - // thisfile is now the most recent version of the file. - } - LL_INFOS("") << "Reading:" << scanResult << LL_ENDL; - return scanResult; + std::sort(allfiles.begin(), allfiles.end()); + scanResult = directory + allfiles.back(); + // thisfile is now the most recent version of the file. + } + //LL_INFOS("") << "Reading:" << scanResult << LL_ENDL;/* uncomment if you want to verify step, delete on commit */ + return scanResult; } -- cgit v1.2.3 From 379c3858773e9079fbe9b0838b5f7625b5821718 Mon Sep 17 00:00:00 2001 From: Wolfpup Lowenhar Date: Tue, 23 Nov 2010 17:32:00 -0500 Subject: STORM-102: this is to correct a minor issue with ad-hoc conferences so that they do not get date stamped at all since each one is defined as a unique conversation. --- indra/newview/lllogchat.cpp | 46 +++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) (limited to 'indra/newview/lllogchat.cpp') diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index 2fb5ba82ba..0121bbb1ed 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -89,6 +89,16 @@ const static boost::regex TIMESTAMP_AND_STUFF("^(\\[\\d{4}/\\d{1,2}/\\d{1,2}\\s+ */ const static boost::regex NAME_AND_TEXT("([^:]+[:]{1})?(\\s*)(.*)"); +/** + * These are recognizers for matching the names of ad-hoc conferences when generating the log file name + * On invited side, an ad-hoc is named like " Conference 2010/11/19 03:43 f0f4" + * On initiating side, an ad-hoc is named like Ad-hoc Conference hash" + * If the naming system for ad-hoc conferences are change in LLIMModel::LLIMSession::buildHistoryFileName() + * then these definition need to be adjusted as well. + */ +const static boost::regex INBOUND_CONFERENCE("^[a-zA-Z]{1,31} [a-zA-Z]{1,31} Conference [0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2} [0-9a-f]{4}"); +const static boost::regex OUTBOUND_CONFERENCE("^Ad-hoc Conference hash[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"); + //is used to parse complex object names like "Xstreet SL Terminal v2.2.5 st" const static std::string NAME_TEXT_DIVIDER(": "); @@ -182,25 +192,37 @@ private: //static std::string LLLogChat::makeLogFileName(std::string filename) { - if( gSavedPerAccountSettings.getBOOL("LogFileNamewithDate") ) + /** + * Testing for in bound and out bound ad-hoc file names + * if it is then skip date stamping. + **/ + //LL_INFOS("") << "Befor:" << filename << LL_ENDL;/* uncomment if you want to verify step, delete on commit */ + boost::match_results matches; + bool inboundConf = boost::regex_match(filename, matches, INBOUND_CONFERENCE); + bool outboundConf = boost::regex_match(filename, matches, OUTBOUND_CONFERENCE); + if (!(inboundConf || outboundConf)) { - time_t now; - time(&now); - char dbuffer[20]; /* Flawfinder: ignore */ - if (filename == "chat") + if( gSavedPerAccountSettings.getBOOL("LogFileNamewithDate") ) { - strftime(dbuffer, 20, "-%Y-%m-%d", localtime(&now)); - } - else - { - strftime(dbuffer, 20, "-%Y-%m", localtime(&now)); + 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 += dbuffer; } + //LL_INFOS("") << "After:" << filename << LL_ENDL;/* uncomment if you want to verify step, delete on commit */ 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 */ + //LL_INFOS("") << "Full:" << filename << LL_ENDL;/* uncomment if you want to verify step, delete on commit */ return filename; } -- cgit v1.2.3