SL-10505 FIXED Right clicking on any name in Friends list accesses every chat .txt file stored

meow-7.2.2
maxim_productengine 2019-02-12 11:24:37 +02:00
parent 3a8053eb9f
commit 6f1e08f22d
2 changed files with 53 additions and 87 deletions

View File

@ -573,40 +573,10 @@ void LLLogChat::findTranscriptFiles(std::string pattern, std::vector<std::string
while (iter.next(filename))
{
std::string fullname = gDirUtilp->add(dirname, filename);
LLFILE * filep = LLFile::fopen(fullname, "rb");
if (NULL != filep)
if (isTranscriptFileFound(fullname))
{
if(makeLogFileName("chat")== fullname)
{
//Add Nearby chat history to the list of transcriptions
list_of_transcriptions.push_back(gDirUtilp->add(dirname, filename));
LLFile::close(filep);
continue;
}
char buffer[LOG_RECALL_SIZE];
fseek(filep, 0, SEEK_END); // seek to end of file
S32 bytes_to_read = ftell(filep); // get current file pointer
fseek(filep, 0, SEEK_SET); // seek back to beginning of file
// limit the number characters to read from file
if (bytes_to_read >= LOG_RECALL_SIZE)
{
bytes_to_read = LOG_RECALL_SIZE - 1;
}
if (bytes_to_read > 0 && NULL != fgets(buffer, bytes_to_read, filep))
{
//matching a timestamp
boost::match_results<std::string::const_iterator> matches;
if (boost::regex_match(std::string(buffer), matches, TIMESTAMP))
{
list_of_transcriptions.push_back(gDirUtilp->add(dirname, filename));
}
}
LLFile::close(filep);
}
list_of_transcriptions.push_back(fullname);
}
}
}
@ -756,75 +726,70 @@ void LLLogChat::deleteTranscripts()
// static
bool LLLogChat::isTranscriptExist(const LLUUID& avatar_id, bool is_group)
{
std::vector<std::string> list_of_transcriptions;
LLLogChat::getListOfTranscriptFiles(list_of_transcriptions);
if (list_of_transcriptions.size() > 0)
LLAvatarName avatar_name;
LLAvatarNameCache::get(avatar_id, &avatar_name);
std::string avatar_user_name = avatar_name.getAccountName();
if(!is_group)
{
LLAvatarName avatar_name;
LLAvatarNameCache::get(avatar_id, &avatar_name);
std::string avatar_user_name = avatar_name.getAccountName();
if(!is_group)
{
std::replace(avatar_user_name.begin(), avatar_user_name.end(), '.', '_');
BOOST_FOREACH(std::string& transcript_file_name, list_of_transcriptions)
{
if (std::string::npos != transcript_file_name.find(avatar_user_name))
{
return true;
}
}
}
else
{
std::string file_name;
gCacheName->getGroupName(avatar_id, file_name);
file_name = makeLogFileName(file_name);
BOOST_FOREACH(std::string& transcript_file_name, list_of_transcriptions)
{
if (transcript_file_name == file_name)
{
return true;
}
}
}
std::replace(avatar_user_name.begin(), avatar_user_name.end(), '.', '_');
return isTranscriptFileFound(makeLogFileName(avatar_user_name));
}
else
{
std::string file_name;
gCacheName->getGroupName(avatar_id, file_name);
file_name = makeLogFileName(file_name);
return isTranscriptFileFound(makeLogFileName(file_name));
}
return false;
}
bool LLLogChat::isNearbyTranscriptExist()
{
std::vector<std::string> list_of_transcriptions;
LLLogChat::getListOfTranscriptFiles(list_of_transcriptions);
std::string file_name;
file_name = makeLogFileName("chat");
BOOST_FOREACH(std::string& transcript_file_name, list_of_transcriptions)
{
if (transcript_file_name == file_name)
{
return true;
}
}
return false;
return isTranscriptFileFound(makeLogFileName("chat"));;
}
bool LLLogChat::isAdHocTranscriptExist(std::string file_name)
{
std::vector<std::string> list_of_transcriptions;
LLLogChat::getListOfTranscriptFiles(list_of_transcriptions);
return isTranscriptFileFound(makeLogFileName(file_name));;
}
file_name = makeLogFileName(file_name);
BOOST_FOREACH(std::string& transcript_file_name, list_of_transcriptions)
// static
bool LLLogChat::isTranscriptFileFound(std::string fullname)
{
bool result = false;
LLFILE * filep = LLFile::fopen(fullname, "rb");
if (NULL != filep)
{
if (transcript_file_name == file_name)
{
return true;
if (makeLogFileName("chat") == fullname)
{
LLFile::close(filep);
return true;
}
char buffer[LOG_RECALL_SIZE];
fseek(filep, 0, SEEK_END); // seek to end of file
S32 bytes_to_read = ftell(filep); // get current file pointer
fseek(filep, 0, SEEK_SET); // seek back to beginning of file
// limit the number characters to read from file
if (bytes_to_read >= LOG_RECALL_SIZE)
{
bytes_to_read = LOG_RECALL_SIZE - 1;
}
if (bytes_to_read > 0 && NULL != fgets(buffer, bytes_to_read, filep))
{
//matching a timestamp
boost::match_results<std::string::const_iterator> matches;
if (boost::regex_match(std::string(buffer), matches, TIMESTAMP))
{
result = true;
}
}
LLFile::close(filep);
}
return false;
return result;
}
//*TODO mark object's names in a special way so that they will be distinguishable form avatar name

View File

@ -121,6 +121,7 @@ public:
static bool isTranscriptExist(const LLUUID& avatar_id, bool is_group=false);
static bool isNearbyTranscriptExist();
static bool isAdHocTranscriptExist(std::string file_name);
static bool isTranscriptFileFound(std::string fullname);
static bool historyThreadsFinished(LLUUID session_id);
static LLLoadHistoryThread* getLoadHistoryThread(LLUUID session_id);