From 3781615afa6db7289f26f404885ac614c7f1cee0 Mon Sep 17 00:00:00 2001 From: mberezhnoy Date: Wed, 6 Feb 2013 10:03:42 +0200 Subject: CHUI-597 (Messages shown in Conversation Log are inaccurate) Added messages, for now they're displayed in two cases: 1) no log entries, logging disabled 2) no log entries, logging enabled Case when there are existing log entries and logging is disabled is still under discussion --- indra/newview/llconversationlog.cpp | 5 +++-- indra/newview/llconversationlog.h | 5 +++++ indra/newview/llconversationloglist.cpp | 24 +++++++++++++++++++++- indra/newview/llfloaterconversationlog.cpp | 9 -------- indra/newview/llfloaterconversationlog.h | 2 -- .../default/xui/en/floater_conversation_log.xml | 3 --- indra/newview/skins/default/xui/en/strings.xml | 11 ++++++++++ 7 files changed, 42 insertions(+), 17 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llconversationlog.cpp b/indra/newview/llconversationlog.cpp index 7bd6ef8cd7..5f037549ab 100644 --- a/indra/newview/llconversationlog.cpp +++ b/indra/newview/llconversationlog.cpp @@ -187,7 +187,8 @@ void LLConversationLogFriendObserver::changed(U32 mask) /************************************************************************/ LLConversationLog::LLConversationLog() : - mAvatarNameCacheConnection() + mAvatarNameCacheConnection(), + mLoggingEnabled(false) { LLControlVariable * keep_log_ctrlp = gSavedSettings.getControl("KeepConversationLogTranscripts").get(); S32 log_mode = keep_log_ctrlp->getValue(); @@ -202,6 +203,7 @@ LLConversationLog::LLConversationLog() : void LLConversationLog::enableLogging(S32 log_mode) { + mLoggingEnabled = log_mode > 0; if (log_mode > 0) { LLIMMgr::instance().addSessionObserver(this); @@ -217,7 +219,6 @@ void LLConversationLog::enableLogging(S32 log_mode) LLIMMgr::instance().removeSessionObserver(this); mNewMessageSignalConnection.disconnect(); LLAvatarTracker::instance().removeObserver(mFriendObserver); - mConversations.clear(); } notifyObservers(); diff --git a/indra/newview/llconversationlog.h b/indra/newview/llconversationlog.h index 65a18c02e5..d5b6eccb29 100644 --- a/indra/newview/llconversationlog.h +++ b/indra/newview/llconversationlog.h @@ -141,6 +141,9 @@ public: void onClearLog(); void onClearLogResponse(const LLSD& notification, const LLSD& response); + bool getIsLoggingEnabled() { return mLoggingEnabled; } + bool isLogEmpty() { return mConversations.empty(); } + private: LLConversationLog(); @@ -187,6 +190,8 @@ private: boost::signals2::connection mNewMessageSignalConnection; boost::signals2::connection mAvatarNameCacheConnection; + + bool mLoggingEnabled; }; class LLConversationLogObserver diff --git a/indra/newview/llconversationloglist.cpp b/indra/newview/llconversationloglist.cpp index 6dbcb7bef7..96b225b841 100644 --- a/indra/newview/llconversationloglist.cpp +++ b/indra/newview/llconversationloglist.cpp @@ -33,6 +33,7 @@ #include "llconversationloglist.h" #include "llconversationloglistitem.h" #include "llviewermenu.h" +#include "lltrans.h" static LLDefaultChildRegistry::Register r("conversation_log_list"); @@ -200,8 +201,9 @@ void LLConversationLogList::rebuildList() clear(); bool have_filter = !mNameFilter.empty(); + LLConversationLog &log_instance = LLConversationLog::instance(); - const std::vector& conversations = LLConversationLog::instance().getConversations(); + const std::vector& conversations = log_instance.getConversations(); std::vector::const_iterator iter = conversations.begin(); for (; iter != conversations.end(); ++iter) @@ -212,6 +214,26 @@ void LLConversationLogList::rebuildList() addNewItem(&*iter); } + + + bool logging_enabled = log_instance.getIsLoggingEnabled(); + bool log_empty = log_instance.isLogEmpty(); + if (!logging_enabled && log_empty) + { + setNoItemsCommentText(LLTrans::getString("logging_calls_disabled_log_empty")); + } + else if (!logging_enabled && !log_empty) + { + setNoItemsCommentText(LLTrans::getString("logging_calls_disabled_log_not_empty")); + } + else if (logging_enabled && log_empty) + { + setNoItemsCommentText(LLTrans::getString("logging_calls_enabled_log_empty")); + } + else if (logging_enabled && !log_empty) + { + setNoItemsCommentText(""); + } } void LLConversationLogList::onCustomAction(const LLSD& userdata) diff --git a/indra/newview/llfloaterconversationlog.cpp b/indra/newview/llfloaterconversationlog.cpp index 07723ce44d..4c910c5655 100644 --- a/indra/newview/llfloaterconversationlog.cpp +++ b/indra/newview/llfloaterconversationlog.cpp @@ -63,10 +63,6 @@ BOOL LLFloaterConversationLog::postBuild() getChild("people_filter_input")->setCommitCallback(boost::bind(&LLFloaterConversationLog::onFilterEdit, this, _2)); - LLControlVariable * keep_log_ctrlp = gSavedSettings.getControl("KeepConversationLogTranscripts").get(); - keep_log_ctrlp->getSignal()->connect(boost::bind(&LLFloaterConversationLog::onCallLoggingEnabledDisabled, this, _2)); - onCallLoggingEnabledDisabled(keep_log_ctrlp->getValue()); - return LLFloater::postBuild(); } @@ -136,8 +132,3 @@ bool LLFloaterConversationLog::isActionChecked(const LLSD& userdata) return false; } -void LLFloaterConversationLog::onCallLoggingEnabledDisabled(S32 log_mode) -{ - std::string no_items_msg = log_mode > 0 ? "" : getString("logging_calls_disabled"); - mConversationLogList->setNoItemsCommentText(no_items_msg); -} diff --git a/indra/newview/llfloaterconversationlog.h b/indra/newview/llfloaterconversationlog.h index aa0f480aae..e971330f3d 100644 --- a/indra/newview/llfloaterconversationlog.h +++ b/indra/newview/llfloaterconversationlog.h @@ -49,8 +49,6 @@ private: bool isActionEnabled(const LLSD& userdata); bool isActionChecked(const LLSD& userdata); - void onCallLoggingEnabledDisabled(S32 log_mode); - LLConversationLogList* mConversationLogList; }; diff --git a/indra/newview/skins/default/xui/en/floater_conversation_log.xml b/indra/newview/skins/default/xui/en/floater_conversation_log.xml index 256e03c4d7..7229292a14 100644 --- a/indra/newview/skins/default/xui/en/floater_conversation_log.xml +++ b/indra/newview/skins/default/xui/en/floater_conversation_log.xml @@ -13,9 +13,6 @@ reuse_instance="true" title="CONVERSATION LOG" width="300"> - - Conversations are not being logged. To log conversations in the future, select "Save IM logs on my computer" under Preferences > Privacy. - [User] + + + Conversations are not being logged. To begin keeping a log, choose "Save: Log only" or "Save: Log and transcripts" under Preferences > Chat. + + + No more conversations will be logged. To resume keeping a log, choose "Save: Log only" or "Save: Log and transcripts" under Preferences > Chat. + + + There are no logged conversations. After you contact someone, or someone contacts you, a log entry will be shown here. + + -- cgit v1.2.3 From 302f57e47fdab9e043a72e6a83f0f2b1992f2a99 Mon Sep 17 00:00:00 2001 From: Mnikolenko ProductEngine Date: Wed, 6 Feb 2013 20:17:35 +0200 Subject: CHUI-744 FIXED KeepConversationLogTranscripts setting is moved to settings_per_account.xml --- indra/newview/app_settings/settings.xml | 11 ----------- indra/newview/app_settings/settings_per_account.xml | 11 +++++++++++ indra/newview/llconversationlog.cpp | 4 ++-- indra/newview/llfloaterimcontainer.cpp | 4 ++-- indra/newview/llfloaterimnearbychat.cpp | 2 +- indra/newview/llimview.cpp | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index fb4cc6de62..79376f7467 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -4667,17 +4667,6 @@ Value 1 - KeepConversationLogTranscripts - - Comment - Keep a conversation log and transcripts - Persist - 1 - Type - S32 - Value - 2 - LandBrushSize Comment diff --git a/indra/newview/app_settings/settings_per_account.xml b/indra/newview/app_settings/settings_per_account.xml index 6864328339..0b589e2da6 100644 --- a/indra/newview/app_settings/settings_per_account.xml +++ b/indra/newview/app_settings/settings_per_account.xml @@ -281,6 +281,17 @@ Value 0 + KeepConversationLogTranscripts + + Comment + Keep a conversation log and transcripts + Persist + 1 + Type + S32 + Value + 2 + ShowFavoritesOnLogin Comment diff --git a/indra/newview/llconversationlog.cpp b/indra/newview/llconversationlog.cpp index 04abda1799..c5be2f59be 100644 --- a/indra/newview/llconversationlog.cpp +++ b/indra/newview/llconversationlog.cpp @@ -190,7 +190,7 @@ LLConversationLog::LLConversationLog() : mAvatarNameCacheConnection(), mLoggingEnabled(false) { - LLControlVariable * keep_log_ctrlp = gSavedSettings.getControl("KeepConversationLogTranscripts").get(); + LLControlVariable * keep_log_ctrlp = gSavedPerAccountSettings.getControl("KeepConversationLogTranscripts").get(); S32 log_mode = keep_log_ctrlp->getValue(); if (log_mode > 0) @@ -369,7 +369,7 @@ void LLConversationLog::sessionAdded(const LLUUID& session_id, const std::string void LLConversationLog::cache() { - if (gSavedSettings.getS32("KeepConversationLogTranscripts") > 0) + if (gSavedPerAccountSettings.getS32("KeepConversationLogTranscripts") > 0) { saveToFile(getFileName()); } diff --git a/indra/newview/llfloaterimcontainer.cpp b/indra/newview/llfloaterimcontainer.cpp index 5a284cc7b7..2b13ce6377 100644 --- a/indra/newview/llfloaterimcontainer.cpp +++ b/indra/newview/llfloaterimcontainer.cpp @@ -1141,7 +1141,7 @@ bool LLFloaterIMContainer::enableContextMenuItem(const LLSD& userdata) if ("conversation_log" == item) { - return gSavedSettings.getS32("KeepConversationLogTranscripts") > 0; + return gSavedPerAccountSettings.getS32("KeepConversationLogTranscripts") > 0; } //Enable Chat history item for ad-hoc and group conversations @@ -1792,7 +1792,7 @@ void LLFloaterIMContainer::updateSpeakBtnState() bool LLFloaterIMContainer::isConversationLoggingAllowed() { - return gSavedSettings.getS32("KeepConversationLogTranscripts") > 0; + return gSavedPerAccountSettings.getS32("KeepConversationLogTranscripts") > 0; } void LLFloaterIMContainer::flashConversationItemWidget(const LLUUID& session_id, bool is_flashes) diff --git a/indra/newview/llfloaterimnearbychat.cpp b/indra/newview/llfloaterimnearbychat.cpp index 345418bffc..430326203f 100644 --- a/indra/newview/llfloaterimnearbychat.cpp +++ b/indra/newview/llfloaterimnearbychat.cpp @@ -542,7 +542,7 @@ void LLFloaterIMNearbyChat::addMessage(const LLChat& chat,bool archive,const LLS } // logging - if (!args["do_not_log"].asBoolean() && gSavedSettings.getS32("KeepConversationLogTranscripts") > 1) + if (!args["do_not_log"].asBoolean() && gSavedPerAccountSettings.getS32("KeepConversationLogTranscripts") > 1) { std::string from_name = chat.mFromName; diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 1cceb68e2a..d4c8d8c4f4 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -928,7 +928,7 @@ bool LLIMModel::addToHistory(const LLUUID& session_id, const std::string& from, bool LLIMModel::logToFile(const std::string& file_name, const std::string& from, const LLUUID& from_id, const std::string& utf8_text) { - if (gSavedSettings.getS32("KeepConversationLogTranscripts") > 1) + if (gSavedPerAccountSettings.getS32("KeepConversationLogTranscripts") > 1) { std::string from_name = from; -- cgit v1.2.3 From ec0ac12eba9d944ade7bd734226a03ea2eb47229 Mon Sep 17 00:00:00 2001 From: maksymsproductengine Date: Wed, 6 Feb 2013 20:51:14 +0200 Subject: CHUI-712 FIXED IM log files renamed with ll.txt will create double files for users --- indra/newview/llconversationlog.cpp | 8 +- indra/newview/llconversationlog.h | 1 - indra/newview/llfloaterpreference.cpp | 2 +- indra/newview/lllogchat.cpp | 147 ++++++++++++++++++---------------- indra/newview/lllogchat.h | 9 +-- 5 files changed, 82 insertions(+), 85 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llconversationlog.cpp b/indra/newview/llconversationlog.cpp index c5be2f59be..82176b3a06 100644 --- a/indra/newview/llconversationlog.cpp +++ b/indra/newview/llconversationlog.cpp @@ -532,14 +532,8 @@ void LLConversationLog::onClearLogResponse(const LLSD& notification, const LLSD& { if (0 == LLNotificationsUtil::getSelectedOption(notification, response)) { - deleteTranscripts(); + LLLogChat::deleteTranscripts(); mConversations.clear(); notifyObservers(); } } - -void LLConversationLog::deleteTranscripts() -{ - gDirUtilp->deleteFilesInDir(gDirUtilp->getPerAccountChatLogsDir(), "*." + LL_TRANSCRIPT_FILE_EXTENSION); - LLFloaterIMSessionTab::processChatHistoryStyleUpdate(true); -} diff --git a/indra/newview/llconversationlog.h b/indra/newview/llconversationlog.h index 5213c9b3ab..d5b6eccb29 100644 --- a/indra/newview/llconversationlog.h +++ b/indra/newview/llconversationlog.h @@ -140,7 +140,6 @@ public: void onClearLog(); void onClearLogResponse(const LLSD& notification, const LLSD& response); - void deleteTranscripts(); bool getIsLoggingEnabled() { return mLoggingEnabled; } bool isLogEmpty() { return mConversations.empty(); } diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 4f86c26a67..da24bb3b8f 100755 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -1584,7 +1584,7 @@ void LLFloaterPreference::onDeleteTranscriptsResponse(const LLSD& notification, { if (0 == LLNotificationsUtil::getSelectedOption(notification, response)) { - LLConversationLog::instance().deleteTranscripts(); + LLLogChat::deleteTranscripts(); updateDeleteTranscriptsButton(); } } diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index 545b44ef92..17b72c5023 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -33,6 +33,7 @@ #include "llviewercontrol.h" #include "lldiriterator.h" +#include "llfloaterimsessiontab.h" #include "llinstantmessage.h" #include "llsingleton.h" // for LLSingleton @@ -40,6 +41,7 @@ #include #include #include +#include #if LL_MSVC #pragma warning(push) @@ -62,7 +64,7 @@ const std::string LL_IM_TIME("time"); const std::string LL_IM_TEXT("message"); const std::string LL_IM_FROM("from"); const std::string LL_IM_FROM_ID("from_id"); -const std::string LL_TRANSCRIPT_FILE_EXTENSION("ll.txt"); +const std::string LL_TRANSCRIPT_FILE_EXTENSION("txt"); const static std::string IM_SEPARATOR(": "); const static std::string NEW_LINE("\n"); @@ -85,6 +87,7 @@ const static std::string MULTI_LINE_PREFIX(" "); * Note: "You" was used as an avatar names in viewers of previous versions */ const static boost::regex TIMESTAMP_AND_STUFF("^(\\[\\d{4}/\\d{1,2}/\\d{1,2}\\s+\\d{1,2}:\\d{2}\\]\\s+|\\[\\d{1,2}:\\d{2}\\]\\s+)?(.*)$"); +const static boost::regex TIMESTAMP("^(\\[\\d{4}/\\d{1,2}/\\d{1,2}\\s+\\d{1,2}:\\d{2}\\]|\\[\\d{1,2}:\\d{2}\\]).*"); /** * Regular expression suitable to match names like @@ -328,69 +331,6 @@ void LLLogChat::saveHistory(const std::string& filename, } } -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); - } -} - // static void LLLogChat::loadChatHistory(const std::string& file_name, std::list& messages, const LLSD& load_params) { @@ -506,19 +446,46 @@ std::string LLLogChat::oldLogFileName(std::string filename) void LLLogChat::getListOfTranscriptFiles(std::vector& list_of_transcriptions) { // get Users log directory - std::string directory = gDirUtilp->getPerAccountChatLogsDir(); + std::string dirname = gDirUtilp->getPerAccountChatLogsDir(); // add final OS dependent delimiter - directory += gDirUtilp->getDirDelimiter(); + dirname += gDirUtilp->getDirDelimiter(); // create search pattern std::string pattern = "*." + LL_TRANSCRIPT_FILE_EXTENSION; - LLDirIterator iter(directory, pattern); - std::string scanResult; - while (iter.next(scanResult)) + LLDirIterator iter(dirname, pattern); + std::string filename; + while (iter.next(filename)) { - list_of_transcriptions.push_back(scanResult); + std::string fullname = gDirUtilp->add(dirname, filename); + + LLFILE * filep = LLFile::fopen(fullname, "rb"); + if (NULL != filep) + { + 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 matches; + if (boost::regex_match(std::string(buffer), matches, TIMESTAMP)) + { + list_of_transcriptions.push_back(gDirUtilp->add(dirname, filename)); + } + } + LLFile::close(filep); + } } } @@ -533,6 +500,46 @@ boost::signals2::connection LLLogChat::setSaveHistorySignal(const save_history_s return sSaveHistorySignal->connect(cb); } +//static +void LLLogChat::deleteTranscripts() +{ + std::vector list_of_transcriptions; + getListOfTranscriptFiles(list_of_transcriptions); + + BOOST_FOREACH(const std::string& fullpath, list_of_transcriptions) + { + S32 retry_count = 0; + while (retry_count < 5) + { + if (0 != LLFile::remove(fullpath)) + { + retry_count++; + S32 result = errno; + LL_WARNS("LLLogChat::deleteTranscripts") << "Problem removing " << fullpath << " - errorcode: " + << result << " attempt " << retry_count << LL_ENDL; + + if(retry_count >= 5) + { + LL_WARNS("LLLogChat::deleteTranscripts") << "Failed to remove " << fullpath << LL_ENDL; + return; + } + + ms_sleep(100); + } + else + { + if (retry_count) + { + LL_WARNS("LLLogChat::deleteTranscripts") << "Successfully removed " << fullpath << LL_ENDL; + } + break; + } + } + } + + LLFloaterIMSessionTab::processChatHistoryStyleUpdate(true); +} + //*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 written like "Object " diff --git a/indra/newview/lllogchat.h b/indra/newview/lllogchat.h index b35a94b4b3..5fbb4ade96 100644 --- a/indra/newview/lllogchat.h +++ b/indra/newview/lllogchat.h @@ -51,16 +51,13 @@ public: const std::string& line); static void getListOfTranscriptFiles(std::vector& list); - /** @deprecated @see loadChatHistory() */ - static void loadHistory(const std::string& filename, - void (*callback)(ELogLineType, const LLSD&, void*), - void* userdata); - static void loadChatHistory(const std::string& file_name, std::list& messages, const LLSD& load_params = LLSD()); typedef boost::signals2::signal save_history_signal_t; static boost::signals2::connection setSaveHistorySignal(const save_history_signal_t::slot_type& cb); + static void deleteTranscripts(); + private: static std::string cleanFileName(std::string filename); static save_history_signal_t * sSaveHistorySignal; @@ -123,6 +120,6 @@ extern const std::string LL_IM_TIME; //("time"); extern const std::string LL_IM_TEXT; //("message"); extern const std::string LL_IM_FROM; //("from"); extern const std::string LL_IM_FROM_ID; //("from_id"); -extern const std::string LL_TRANSCRIPT_FILE_EXTENSION; //("ll.txt"); +extern const std::string LL_TRANSCRIPT_FILE_EXTENSION; //("txt"); #endif -- cgit v1.2.3