diff options
author | maxim_productengine <mnikolenko@productengine.com> | 2019-02-12 11:24:37 +0200 |
---|---|---|
committer | maxim_productengine <mnikolenko@productengine.com> | 2019-02-12 11:24:37 +0200 |
commit | 6f1e08f22d6cf9330899fd355cb7433897b93b48 (patch) | |
tree | a4940bb7e1d619df02736930428f8af2ee54cb1c /indra | |
parent | 3a8053eb9fc0db52b9fb5ae02f1807acbb4e072d (diff) |
SL-10505 FIXED Right clicking on any name in Friends list accesses every chat .txt file stored
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/lllogchat.cpp | 139 | ||||
-rw-r--r-- | indra/newview/lllogchat.h | 1 |
2 files changed, 53 insertions, 87 deletions
diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index c9889667b4..1bdeddbcfe 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -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 diff --git a/indra/newview/lllogchat.h b/indra/newview/lllogchat.h index 6022e539a9..fcbd38a044 100644 --- a/indra/newview/lllogchat.h +++ b/indra/newview/lllogchat.h @@ -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); |