From 250680a07871001bdb108b5aab33f04847ab823f Mon Sep 17 00:00:00 2001 From: Igor Borovkov Date: Tue, 2 Feb 2010 17:58:29 +0200 Subject: fixed EXT-4755 Own context menu in voice chat participants list has 'Add Friend' and 'Pay' enabled --HG-- branch : product-engine --- indra/newview/lllogchat.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'indra/newview/lllogchat.cpp') diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index dc187bf36c..96ce01c05f 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -138,16 +138,20 @@ void LLLogChat::saveHistory(const std::string& filename, const LLUUID& from_id, const std::string& line) { - if(!filename.size()) + std::string tmp_filename = filename; + LLStringUtil::trim(tmp_filename); + if (tmp_filename.empty()) { - llinfos << "Filename is Empty!" << llendl; + std::string warn = "Chat history filename [" + filename + "] is empty!"; + llwarning(warn, 666); + llassert(tmp_filename.size()); return; } - + llofstream file (LLLogChat::makeLogFileName(filename), std::ios_base::app); if (!file.is_open()) { - llinfos << "Couldn't open chat history log!" << llendl; + llwarns << "Couldn't open chat history log! - " + filename << llendl; return; } -- cgit v1.2.3 From 4c5a998f79e835d1f3436a8f8d1cc920d158fcff Mon Sep 17 00:00:00 2001 From: Igor Borovkov Date: Wed, 17 Feb 2010 16:09:50 +0200 Subject: fixed EXT-5456 Messages from objects are shownas messages from Second Life in nearby chat history from the prev session Completed things which were agreed on: - system messages in the log file are prepended with "Second Life:" after the timestamp - object names set which are parsed extended to object names consisting with any number of words Side effect: "Second Life:" is shown as From Name in Nearby Chat when in plain text chat --HG-- branch : product-engine --- indra/newview/lllogchat.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'indra/newview/lllogchat.cpp') diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index 96ce01c05f..f13445fa5d 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -69,6 +69,8 @@ const static std::string MULTI_LINE_PREFIX(" "); * Katar Ivercourt is Offline * [3:00] Katar Ivercourt is Offline * [2009/11/20 3:01] Corba ProductEngine is Offline + * + * 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+)?(.*)$"); @@ -78,6 +80,9 @@ const static boost::regex TIMESTAMP_AND_STUFF("^(\\[\\d{4}/\\d{1,2}/\\d{1,2}\\s+ */ const static boost::regex NAME_AND_TEXT("(You:|Second Life:|[^\\s:]+\\s*[:]{1}|\\S+\\s+[^\\s:]+[:]{1})?(\\s*)(.*)"); +//is used to parse complex object names like "Xstreet SL Terminal v2.2.5 st" +const static std::string NAME_TEXT_DIVIDER(": "); + const static int IDX_TIMESTAMP = 1; const static int IDX_STUFF = 2; const static int IDX_NAME = 1; @@ -160,10 +165,19 @@ void LLLogChat::saveHistory(const std::string& filename, if (gSavedPerAccountSettings.getBOOL("LogTimestamp")) item["time"] = LLLogChat::timestamp(gSavedPerAccountSettings.getBOOL("LogTimestampDate")); - item["from"] = from; item["from_id"] = from_id; item["message"] = line; + //adding "Second Life:" for all system messages to make chat log history parsing more reliable + if (from.empty() && from_id.isNull()) + { + item["from"] = SYSTEM_FROM; + } + else + { + item["from"] = from; + } + file << LLChatLogFormatter(item) << std::endl; file.close(); @@ -398,6 +412,18 @@ bool LLChatLogParser::parse(std::string& raw, LLSD& im) im[IM_FROM_ID] = LLUUID::null; } + //possibly a case of complex object names consisting of 3+ words + if (!has_name) + { + U32 divider_pos = stuff.find(NAME_TEXT_DIVIDER); + if (divider_pos != std::string::npos && divider_pos < (stuff.length() - NAME_TEXT_DIVIDER.length())) + { + im[IM_FROM] = stuff.substr(0, divider_pos); + im[IM_TEXT] = stuff.substr(divider_pos + NAME_TEXT_DIVIDER.length()); + return true; + } + } + if (!has_name) { //text is mandatory -- cgit v1.2.3 From 10c5f2f080b47561db2b1f9a2f063ad8dcc175b9 Mon Sep 17 00:00:00 2001 From: Eugene Mutavchi Date: Fri, 19 Feb 2010 13:36:47 +0200 Subject: Implemented low task EXT-5215 (Disable showing full yyyy/mm/dd timestamp for messages (nearby chat/im) received today) --HG-- branch : product-engine --- indra/newview/lllogchat.cpp | 90 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 1 deletion(-) (limited to 'indra/newview/lllogchat.cpp') diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index f13445fa5d..3650b43364 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -39,12 +39,17 @@ #include "llviewercontrol.h" #include "llinstantmessage.h" +#include "llsingleton.h" // for LLSingleton #include #include #include #include +#include +#include +#include + const S32 LOG_RECALL_SIZE = 2048; const static std::string IM_TIME("time"); @@ -83,11 +88,93 @@ const static boost::regex NAME_AND_TEXT("(You:|Second Life:|[^\\s:]+\\s*[:]{1}|\ //is used to parse complex object names like "Xstreet SL Terminal v2.2.5 st" const static std::string NAME_TEXT_DIVIDER(": "); +// is used for timestamps adjusting +const static char* DATE_FORMAT("%Y/%m/%d %H:%M"); +const static char* TIME_FORMAT("%H:%M"); + const static int IDX_TIMESTAMP = 1; const static int IDX_STUFF = 2; const static int IDX_NAME = 1; const static int IDX_TEXT = 3; +using namespace boost::posix_time; +using namespace boost::gregorian; + +class LLLogChatTimeScaner: public LLSingleton +{ +public: + LLLogChatTimeScaner() + { + // Note, date/time facets will be destroyed by string streams + mDateStream.imbue(std::locale(mDateStream.getloc(), new date_input_facet(DATE_FORMAT))); + mTimeStream.imbue(std::locale(mTimeStream.getloc(), new time_facet(TIME_FORMAT))); + mTimeStream.imbue(std::locale(mTimeStream.getloc(), new time_input_facet(DATE_FORMAT))); + } + + date getTodayPacificDate() + { + typedef boost::date_time::local_adjustor pst; + typedef boost::date_time::local_adjustor pdt; + time_t t_time = time(NULL); + ptime p_time = LLStringOps::getPacificDaylightTime() + ? pdt::utc_to_local(from_time_t(t_time)) + : pst::utc_to_local(from_time_t(t_time)); + struct tm s_tm = to_tm(p_time); + return date_from_tm(s_tm); + } + + void checkAndCutOffDate(std::string& time_str) + { + // Cuts off the "%Y/%m/%d" from string for todays timestamps. + // Assume that passed string has at least "%H:%M" time format. + date log_date(not_a_date_time); + date today(getTodayPacificDate()); + + // Parse the passed date + mDateStream.str(LLStringUtil::null); + mDateStream << time_str; + mDateStream >> log_date; + mDateStream.clear(); + + days zero_days(0); + days days_alive = today - log_date; + + if ( days_alive == zero_days ) + { + // Yep, today's so strip "%Y/%m/%d" info + ptime stripped_time(not_a_date_time); + + mTimeStream.str(LLStringUtil::null); + mTimeStream << time_str; + mTimeStream >> stripped_time; + mTimeStream.clear(); + + time_str.clear(); + + mTimeStream.str(LLStringUtil::null); + mTimeStream << stripped_time; + mTimeStream >> time_str; + mTimeStream.clear(); + } + + LL_DEBUGS("LLChatLogParser") + << " log_date: " + << log_date + << " today: " + << today + << " days alive: " + << days_alive + << " new time: " + << time_str + << LL_ENDL; + } + + +private: + std::stringstream mDateStream; + std::stringstream mTimeStream; +}; + //static std::string LLLogChat::makeLogFileName(std::string filename) { @@ -377,7 +464,8 @@ bool LLChatLogParser::parse(std::string& raw, LLSD& im) boost::trim(timestamp); timestamp.erase(0, 1); timestamp.erase(timestamp.length()-1, 1); - im[IM_TIME] = timestamp; + LLLogChatTimeScaner::instance().checkAndCutOffDate(timestamp); + im[IM_TIME] = timestamp; } else { -- cgit v1.2.3 From 2a089e25ba1c2228d0c3bf2e6a6b6efe0e1882ba Mon Sep 17 00:00:00 2001 From: Eugene Mutavchi Date: Fri, 19 Feb 2010 17:55:45 +0200 Subject: No ticket, fixed the mistake in class name. --HG-- branch : product-engine --- indra/newview/lllogchat.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/lllogchat.cpp') diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index 3650b43364..16b13d9218 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -100,10 +100,10 @@ const static int IDX_TEXT = 3; using namespace boost::posix_time; using namespace boost::gregorian; -class LLLogChatTimeScaner: public LLSingleton +class LLLogChatTimeScanner: public LLSingleton { public: - LLLogChatTimeScaner() + LLLogChatTimeScanner() { // Note, date/time facets will be destroyed by string streams mDateStream.imbue(std::locale(mDateStream.getloc(), new date_input_facet(DATE_FORMAT))); @@ -464,7 +464,7 @@ bool LLChatLogParser::parse(std::string& raw, LLSD& im) boost::trim(timestamp); timestamp.erase(0, 1); timestamp.erase(timestamp.length()-1, 1); - LLLogChatTimeScaner::instance().checkAndCutOffDate(timestamp); + LLLogChatTimeScanner::instance().checkAndCutOffDate(timestamp); im[IM_TIME] = timestamp; } else -- cgit v1.2.3