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.
master
Wolfpup Lowenhar 2010-11-11 22:50:14 -05:00
parent 899f470dec
commit 4077e6bb52
2 changed files with 30 additions and 28 deletions

View File

@ -537,7 +537,8 @@ bool LLIMModel::LLIMSession::isOtherParticipantAvaline()
void LLIMModel::LLIMSession::onAvatarNameCache(const LLUUID& avatar_id, const LLAvatarName& av_name)
{
if (av_name.mLegacyFirstName.empty())
mHistoryFileName = av_name.mUsername;
/*if (av_name.mLegacyFirstName.empty())
{
// if mLegacyFirstName is empty it means display names is off and the
// data came from the gCacheName, mDisplayName will be the legacy name
@ -546,7 +547,7 @@ void LLIMModel::LLIMSession::onAvatarNameCache(const LLUUID& avatar_id, const LL
else
{
mHistoryFileName = LLCacheName::cleanFullName(av_name.getLegacyName());
}
}*/
}
void LLIMModel::LLIMSession::buildHistoryFileName()

View File

@ -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<LLSD>& 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<std::string> 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<std::string> 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;
//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;/* uncomment if you want to verify step, delete on commit */
return scanResult;
}