[sldev] Chat Logging patch

Harold Brown labrat.hb at gmail.com
Sat May 5 02:10:05 PDT 2007


Skipped content of type multipart/alternative-------------- next part --------------
--- indra/newview/skins/xui/en-us/panel_preferences_im.xml	Wed Apr 25 12:22:02 2007
+++ indra/newview/skins/xui/en-us/panel_preferences_im.xml	Sat May 05 00:39:03 2007
@@ -25,42 +25,65 @@
 	     height="16" hidden="false" initial_value="false"
 	     label="Send IM to Email ([EMAIL])" left="148" mouse_opaque="true"
 	     name="send_im_to_email" radio_style="false" width="350" />
 	<check_box bottom="-65" control_name="IMInChatHistory" enabled="true" follows="left|top"
 	     font="SansSerifSmall" height="16" hidden="false" initial_value="false"
 	     label="Include IM in Chat History" left="148" mouse_opaque="true"
 	     name="include_im_in_chat_history" radio_style="false" width="237" />
 	<check_box bottom="-85" control_name="IMShowTimestamps" enabled="true" follows="left|top"
 	     font="SansSerifSmall" height="16" hidden="false" initial_value="false"
 	     label="Show timestamps in IM" left="148" mouse_opaque="true"
 	     name="show_timestamps_check" radio_style="false" width="237" />
-	<check_box bottom="-105" control_name="LogInstantMessages" enabled="true"
+	<text type="string" length="1" bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
+	     bottom="-105" drop_shadow_visible="true" enabled="true" follows="left|top"
+	     font="SansSerifSmall" h_pad="0" halign="left" height="10" hidden="false"
+	     left="12" mouse_opaque="false" name="text_box3" v_pad="0" width="128">
+		Busy Mode Response:
+	</text>
+	<text_editor type="string" length="1" bottom="-165" embedded_items="false" enabled="true" follows="left|top"
+	     font="SansSerifSmall" height="70" hidden="false" left="148"
+	     max_length="255" mouse_opaque="true" name="busy_response" width="330"
+	     word_wrap="true" />
+	<text type="string" length="1" bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
+	     bottom="-185" drop_shadow_visible="true" enabled="true" follows="left|top"
+	     font="SansSerifSmall" h_pad="0" halign="left" height="10" hidden="false"
+	     left="12" mouse_opaque="false" name="text_box3" v_pad="0" width="128">
+		Logging Options:
+	</text>	
+	<check_box bottom="-205" control_name="LogInstantMessages" enabled="true"
 	     follows="left|top" font="SansSerifSmall" height="16" hidden="false"
 	     initial_value="false" label="Log Instant Messages" left="148"
 	     mouse_opaque="true" name="log_instant_messages" radio_style="false"
 	     width="237" />
-	<check_box bottom="-125" control_name="LogChat" enabled="true" follows="left|top"
+	<check_box bottom="-225" control_name="IMLogTimestamp" enabled="true"
+	     follows="left|top" font="SansSerifSmall" height="16" hidden="false"
+	     initial_value="false" label="Show timestamps in IM Log" left="148"
+	     mouse_opaque="true" name="log_instant_messages_timestamp" radio_style="false"
+	     width="237" />
+	<check_box bottom="-245" control_name="LogShowHistory" enabled="true" follows="left|top"
+	     font="SansSerifSmall" height="16" hidden="false" initial_value="false"
+	     label="Show end of last IM conversation" left="148" mouse_opaque="true"
+	     name="log_show_history" radio_style="false" width="237" />	
+	<check_box bottom="-265" control_name="LogChat" enabled="true" follows="left|top"
 	     font="SansSerifSmall" height="16" hidden="false" initial_value="false"
 	     label="Log Chat" left="148" mouse_opaque="true" name="log_chat"
 	     radio_style="false" width="237" />
-	<check_box bottom="-145" control_name="LogShowHistory" enabled="true" follows="left|top"
+	<check_box bottom="-285" control_name="LogChatTimestamp" enabled="true" follows="left|top"
 	     font="SansSerifSmall" height="16" hidden="false" initial_value="false"
-	     label="Show end of last IM conversation" left="148" mouse_opaque="true"
-	     name="log_show_history" radio_style="false" width="237" />
-	<button bottom="-167" follows="right|bottom" font="SansSerif" halign="center"
+	     label="Show timestamps in Chat Log" left="148" mouse_opaque="true" name="log_chat_timestamp"
+	     radio_style="false" width="237" />
+	<check_box bottom="-305" control_name="LogChatIM" enabled="true" follows="left|top"
+	     font="SansSerifSmall" height="16" hidden="false" initial_value="false"
+	     label="Show incoming IM in Chat Log" left="148" mouse_opaque="true" name="log_chat_IM"
+	     radio_style="false" width="237" />
+	<check_box bottom="-325" control_name="LogTimestampDate" enabled="true" follows="left|top"
+	     font="SansSerifSmall" height="16" hidden="false" initial_value="false"
+	     label="Include Date with Timestamp" left="148" mouse_opaque="true" name="log_date_timestamp"
+	     radio_style="false" width="237" />
+	<button bottom="-347" follows="right|bottom" font="SansSerif" halign="center"
 	     height="20" label="Change Path" label_selected="Change Path" left="170"
 	     mouse_opaque="true" name="log_path_button" width="90" />
-	<line_editor border_drop_shadow_visible="false" border_visible="false" bottom="-166"
+	<line_editor border_drop_shadow_visible="false" border_visible="false" bottom="-346"
 	     drop_shadow_visible="true" enabled="false" follows="top|left|right"
 	     font="SansSerifSmall" halign="right" height="19" left="248"
-	     max_length="254" mouse_opaque="false" name="log_path_string" right="-20" />
-	<text type="string" length="1" bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
-	     bottom="-195" drop_shadow_visible="true" enabled="true" follows="left|top"
-	     font="SansSerifSmall" h_pad="0" halign="left" height="10" hidden="false"
-	     left="12" mouse_opaque="false" name="text_box3" v_pad="0" width="128">
-		Busy Mode Response:
-	</text>
-	<text_editor type="string" length="1" bottom="-255" embedded_items="false" enabled="true" follows="left|top"
-	     font="SansSerifSmall" height="70" hidden="false" left="148"
-	     max_length="255" mouse_opaque="true" name="busy_response" width="330"
-	     word_wrap="true" />
+	     max_length="254" mouse_opaque="false" name="log_path_string" right="-20" />	
 </panel>
--- indra/newview/llcontroldef.cpp	Wed Apr 25 12:21:58 2007
+++ indra/newview/llcontroldef.cpp	Sat May 05 00:30:35 2007
@@ -815,22 +815,26 @@
 
 	// Chat floater
 	// Rectangle should almost fill the bottom of the screen on 800x600
 	// Note that the saved rect size is the size with history shown.
 	gSavedSettings.declareRect("FloaterChatRect",			LLRect( 0, 10*16 + 12, 500, 0 ), "Rectangle for chat history");
 	gSavedSettings.declareRect("FloaterMuteRect3",			LLRect( 0, 300, 300, 0), "Rectangle for mute window");
 	gSavedPerAccountSettings.declareString("BusyModeResponse",		"The Resident you messaged is in 'busy mode' which means they have requested not to be disturbed.  Your message will still be shown in their IM panel for later viewing.", "Auto response to instant messages while in busy mode.");
 	gSavedPerAccountSettings.declareString("InstantMessageLogPath",	"", "Path to your log files.");
 	gSavedPerAccountSettings.declareBOOL("LogInstantMessages",	FALSE, "Log Instant Messages");
 	gSavedPerAccountSettings.declareBOOL("LogChat",	FALSE, "Log Chat");
 	gSavedPerAccountSettings.declareBOOL("LogShowHistory",	FALSE, "Log Show History");
+	gSavedPerAccountSettings.declareBOOL("IMLogTimestamp",	FALSE, "Log Timestamp of Instant Messages");
+	gSavedPerAccountSettings.declareBOOL("LogChatTimestamp",	FALSE, "Log Timestamp of Chat");
+	gSavedPerAccountSettings.declareBOOL("LogChatIM",	FALSE, "Log Incoming Instant Messages with Chat");
+	gSavedPerAccountSettings.declareBOOL("LogTimestampDate",	FALSE, "Include Date with Timestamp");
 
 	// Inventory
 	gSavedSettings.declareRect("FloaterInventoryRect", LLRect(0, 400, 300, 0), "Rectangle for inventory window" );
 
 	// properties, only width and height is used.
 	gSavedSettings.declareRect("PropertiesRect", LLRect(0, 320, 350, 0), "Rectangle for inventory item properties window");
 
 	// Previews - only width and height are used
 	gSavedSettings.declareRect("PreviewTextureRect",			LLRect(0, 400, 400, 0), "Rectangle for texture preview window" );  // Only width and height are used
 	gSavedSettings.declareRect("PreviewScriptRect",				LLRect(0, 550, 500, 0), "Rectangle for script preview window" );  // Only width and height are used
 	gSavedSettings.declareRect("LSLHelpRect",					LLRect(0, 500, 600, 0), "Rectangle for LSL help window" );  // Only width and height are used
--- indra/newview/llfloaterchat.cpp	Wed Apr 25 12:22:00 2007
+++ indra/newview/llfloaterchat.cpp	Sat May 05 01:17:16 2007
@@ -142,28 +142,38 @@
 void add_timestamped_line(LLViewerTextEditor* edit, const LLString& line, const LLColor4& color)
 {
 	bool prepend_newline = true;
 	if (gSavedSettings.getBOOL("ChatShowTimestamps"))
 	{
 		edit->appendTime(prepend_newline);
 		prepend_newline = false;
 	}
 	edit->appendColoredText(line, false, prepend_newline, color);
 }
 
+void log_chat_text(const LLChat& chat)
+{
+		LLString histstr;
+		if (gSavedPerAccountSettings.getBOOL("LogChatTimestamp"))
+			histstr = LLLogChat::timestamp(gSavedPerAccountSettings.getBOOL("LogTimestampDate")) + chat.mText;
+		else
+			histstr = chat.mText;
+
+		LLLogChat::saveHistory("chat",histstr);
+}
 // static
 void LLFloaterChat::addChatHistory(const LLChat& chat, bool log_to_file)
 {
 	if ( gSavedPerAccountSettings.getBOOL("LogChat") && log_to_file) 
 	{
-		LLLogChat::saveHistory("chat",chat.mText);
+		log_chat_text(chat);
 	}
 	
 	LLColor4 color = get_text_color(chat);
 	
 	if (!log_to_file) color = LLColor4::grey;	//Recap from log file.
 
 	if (chat.mChatType == CHAT_TYPE_DEBUG_MSG)
 	{
 		LLFloaterScriptDebug::addScriptLine(chat.mText,
 											chat.mFromName, 
 											color, 
@@ -356,26 +366,30 @@
 		&& !local_agent)
 	{
 		F32 size = CHAT_MSG_SIZE;
 		if(from_instant_message)
 		{
 			text_color = INSTANT_MSG_COLOR;
 			size = INSTANT_MSG_SIZE;
 		}
 		gConsole->addLine(chat.mText, size, text_color);
 	}
 
-	if( !from_instant_message || gSavedSettings.getBOOL("IMInChatHistory") )
-	{
+	if(from_instant_message && gSavedPerAccountSettings.getBOOL("LogChatIM"))
+		log_chat_text(chat);
+	
+	if(from_instant_message && gSavedSettings.getBOOL("IMInChatHistory"))
+		addChatHistory(chat,false);
+	
+	if(!from_instant_message)
 		addChatHistory(chat);
-	}
 }
 
 LLColor4 get_text_color(const LLChat& chat)
 {
 	LLColor4 text_color;
 
 	if(chat.mMuted)
 	{
 		text_color.setVec(0.8f, 0.8f, 0.8f, 1.f);
 	}
 	else
--- indra/newview/llimpanel.cpp	Wed Apr 25 12:22:00 2007
+++ indra/newview/llimpanel.cpp	Sat May 05 00:38:59 2007
@@ -403,23 +403,27 @@
 	bool prepend_newline = true;
 	if (gSavedSettings.getBOOL("IMShowTimestamps"))
 	{
 		timestring = mHistoryEditor->appendTime(prepend_newline);
 		prepend_newline = false;
 	}
 	mHistoryEditor->appendColoredText(utf8msg, false, prepend_newline, color);
 	
 	if (log_to_file
 		&& gSavedPerAccountSettings.getBOOL("LogInstantMessages") ) 
 	{
-		LLString histstr =  timestring + utf8msg;
+		LLString histstr;
+		if (gSavedPerAccountSettings.getBOOL("IMLogTimestamp"))
+			histstr = LLLogChat::timestamp(gSavedPerAccountSettings.getBOOL("LogTimestampDate")) + utf8msg;
+		else
+			histstr = utf8msg;
 
 		LLLogChat::saveHistory(getTitle(),histstr);
 	}
 }
 
 
 void LLFloaterIMPanel::setVisible(BOOL b)
 {
 	LLPanel::setVisible(b);
 
 	LLMultiFloater* hostp = getHost();
--- indra/newview/lllogchat.cpp	Wed Apr 25 12:22:00 2007
+++ indra/newview/lllogchat.cpp	Sat May 05 01:19:08 2007
@@ -20,27 +20,50 @@
  * By copying, modifying or distributing this software, you acknowledge
  * that you have read and understood your obligations described above,
  * and agree to abide by those obligations.
  * 
  * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  * COMPLETENESS OR PERFORMANCE.
  */
 
 #include "llviewerprecompiledheaders.h"
 
+#include "viewer.h"	// for gPacificDaylightTime
 #include "lllogchat.h"
 
 const S32 LOG_RECALL_SIZE = 2048;
 
 //static
+
+LLString LLLogChat::timestamp(bool withdate)
+{
+	U32 utc_time;
+	utc_time = time_corrected();
+
+	// There's only one internal tm buffer.
+	struct tm* timep;
+
+	// Convert to Pacific, based on server's opinion of whether
+	// it's daylight savings time there.
+	timep = utc_to_pacific_time(utc_time, gPacificDaylightTime);
+
+	LLString text;
+	if (withdate)
+		text = llformat("[%d/%02d/%02d %d:%02d]  ", (timep->tm_year-100)+2000, timep->tm_mon+1, timep->tm_mday, timep->tm_hour, timep->tm_min);
+	else
+		text = llformat("[%d:%02d]  ", timep->tm_hour, timep->tm_min);
+
+	return text;
+}
+
 LLString LLLogChat::makeLogFileName(LLString filename)
 {
 	
 	filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_ACCOUNT_CHAT_LOGS,filename.c_str());
 	filename += ".txt";
 	return filename;
 }
 
 //static
 void LLLogChat::saveHistory(LLString filename, LLString line)
 {
--- indra/newview/lllogchat.h	Wed Apr 25 12:21:56 2007
+++ indra/newview/lllogchat.h	Sat May 05 00:13:40 2007
@@ -25,17 +25,18 @@
  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  * COMPLETENESS OR PERFORMANCE.
  */
 
 
 #ifndef LL_LLLOGCHAT_H
 #define LL_LLLOGCHAT_H
 
 class LLLogChat
 {
 public:
+	static LLString timestamp(bool withdate = false);
 	static LLString makeLogFileName(LLString(filename));
 	static void saveHistory(LLString filename, LLString line);
 	static void loadHistory(LLString filename, void (*callback)(LLString,void*),void* userdata);
 };
 
 #endif
--- indra/newview/llprefsim.cpp	Wed Apr 25 12:21:58 2007
+++ indra/newview/llprefsim.cpp	Sat May 05 00:30:02 2007
@@ -60,22 +60,27 @@
 		const std::string& email);
 	void enableHistory();
 	static void onClickLogPath(void* user_data);
 	static void onCommitLogging( LLUICtrl* ctrl, void* user_data);
 
 protected:
 	BOOL mIMInChatHistory;
 	BOOL mLogInstantMessages;
 	BOOL mLogChat;
 	BOOL mLogShowHistory;
 	BOOL mShowTimestamps;
+	BOOL mIMLogTimestamp;
+	BOOL mLogChatTimestamp;
+	BOOL mLogIMChat;
+	BOOL mLogTimestampDate;
+
 	LLString mIMBusyResponse;
 	LLString mLogPath;
 
 	bool mGotPersonalInfo;
 	bool mOriginalIMViaEmail;
 
 	// online status info
 	bool mOriginalHideOnlineStatus;
 	std::string mDirectoryVisibility;
 };
 
@@ -87,33 +92,41 @@
 }
 
 void LLPrefsIMImpl::refresh()
 {
 	mIMInChatHistory   = gSavedSettings.getBOOL("IMInChatHistory");
 	mShowTimestamps    = gSavedSettings.getBOOL("IMShowTimestamps");
 	mIMBusyResponse    = gSavedPerAccountSettings.getString("BusyModeResponse");
 	mLogPath           = gSavedPerAccountSettings.getString("InstantMessageLogPath");
 	mLogInstantMessages= gSavedPerAccountSettings.getBOOL("LogInstantMessages");
 	mLogChat           = gSavedPerAccountSettings.getBOOL("LogChat");
 	mLogShowHistory    = gSavedPerAccountSettings.getBOOL("LogShowHistory");
+	mIMLogTimestamp	   = gSavedPerAccountSettings.getBOOL("IMLogTimestamp");
+	mLogChatTimestamp  = gSavedPerAccountSettings.getBOOL("LogChatTimestamp");
+	mLogIMChat         = gSavedPerAccountSettings.getBOOL("LogChatIM");
+	mLogTimestampDate  = gSavedPerAccountSettings.getBOOL("LogTimestampDate");
 }
 
 void LLPrefsIMImpl::cancel()
 {
 	gSavedSettings.setBOOL("IMInChatHistory", mIMInChatHistory);
 	gSavedSettings.setBOOL("IMShowTimestamps", mShowTimestamps);
 	gSavedPerAccountSettings.setString("BusyModeResponse", mIMBusyResponse);
 	gSavedPerAccountSettings.setString("InstantMessageLogPath",mLogPath);
 	gSavedPerAccountSettings.setBOOL("LogInstantMessages",mLogInstantMessages);
 	gSavedPerAccountSettings.setBOOL("LogChat",mLogChat);
 	gSavedPerAccountSettings.setBOOL("LogShowHistory",mLogShowHistory);
+	gSavedPerAccountSettings.setBOOL("IMLogTimestamp",mIMLogTimestamp);
+	gSavedPerAccountSettings.setBOOL("LogChatTimestamp",mLogChatTimestamp);
+	gSavedPerAccountSettings.setBOOL("LogChatIM",mLogIMChat);
+	gSavedPerAccountSettings.setBOOL("LogTimestampDate",mLogTimestampDate);
 }
 
 BOOL LLPrefsIMImpl::postBuild()
 {
 	requires("online_visibility");
 	requires("send_im_to_email");
 	if (!checkRequirements())
 	{
 		return FALSE;
 	}
 
@@ -122,31 +135,39 @@
 	mOriginalHideOnlineStatus = true;
 	childSetLabelArg("send_im_to_email", "[EMAIL]", childGetText("log_in_to_change"));
 
 	// Don't enable this until we get personal data
 	childDisable("online_visibility");
 	childDisable("send_im_to_email");
 	childDisable("log_instant_messages");
 	childDisable("log_chat");
 	childDisable("log_show_history");
 	childDisable("log_path_button");
 	childDisable("busy_response");
+	childDisable("log_instant_messages_timestamp");
+	childDisable("log_chat_timestamp");
+	childDisable("log_chat_IM");
+	childDisable("log_date_timestamp");
 
 	childSetText("busy_response", childGetText("log_in_to_change"));
 	
 	refresh(); 
 
 	childSetText("log_path_string", mLogPath);
 	childSetValue("log_instant_messages", mLogInstantMessages); 
 	childSetValue("log_chat", mLogChat); 
-	childSetValue("log_show_history", mLogShowHistory); 
+	childSetValue("log_show_history", mIMLogTimestamp);
+	childSetValue("log_instant_messages_timestamp", mIMLogTimestamp);
+	childSetValue("log_chat_timestamp", mLogChatTimestamp);
+	childSetValue("log_chat_IM", mLogIMChat);
+	childSetValue("log_date_timestamp",mLogTimestampDate);
 	childSetAction("log_path_button", onClickLogPath, this);
 	childSetCommitCallback("log_chat",onCommitLogging,this);
 	childSetCommitCallback("log_instant_messages",onCommitLogging,this);
 	
 	return TRUE;
 }
 
 void LLPrefsIMImpl::enableHistory()
 {
 	
 	if (childGetValue("log_instant_messages").asBoolean() || childGetValue("log_chat").asBoolean())
@@ -171,22 +192,26 @@
 	LLWString::replaceChar(busy_response, ' ', '%');
 	
 	if(mGotPersonalInfo)
 	{ 
 
 		gSavedPerAccountSettings.setString("BusyModeResponse", LLString(wstring_to_utf8str(busy_response)));
 
 		gSavedPerAccountSettings.setString("InstantMessageLogPath", childGetText("log_path_string").c_str());
 		gSavedPerAccountSettings.setBOOL("LogInstantMessages",childGetValue("log_instant_messages").asBoolean());
 		gSavedPerAccountSettings.setBOOL("LogChat",childGetValue("log_chat").asBoolean());
 		gSavedPerAccountSettings.setBOOL("LogShowHistory",childGetValue("log_show_history").asBoolean());
+		gSavedPerAccountSettings.setBOOL("IMLogTimestamp",childGetValue("log_instant_messages_timestamp").asBoolean());
+		gSavedPerAccountSettings.setBOOL("LogChatTimestamp",childGetValue("log_chat_timestamp").asBoolean());
+		gSavedPerAccountSettings.setBOOL("LogChatIM",childGetValue("log_chat_IM").asBoolean());
+		gSavedPerAccountSettings.setBOOL("LogTimestampDate",childGetValue("log_date_timestamp").asBoolean());
 
 		gDirUtilp->setChatLogsDir(gSavedPerAccountSettings.getString("InstantMessageLogPath"));
 
 		gDirUtilp->setPerAccountChatLogsDir(gSavedSettings.getString("FirstName").c_str(), 
 											gSavedSettings.getString("LastName").c_str() );
 		LLFile::mkdir(gDirUtilp->getPerAccountChatLogsDir().c_str());
 		
 		bool new_im_via_email = childGetValue("send_im_to_email").asBoolean();
 		bool new_hide_online = childGetValue("online_visibility").asBoolean();		
 
 		if((new_im_via_email != mOriginalIMViaEmail)
@@ -238,22 +263,26 @@
 	else
 	{
 		mOriginalHideOnlineStatus = true;
 	}
 	childSetValue("online_visibility", mOriginalHideOnlineStatus); 	 
 	childSetLabelArg("online_visibility", "[DIR_VIS]", mDirectoryVisibility);
 	childEnable("send_im_to_email");
 	childSetValue("send_im_to_email", im_via_email);
 	childEnable("log_instant_messages");
 	childEnable("log_chat");
 	childEnable("busy_response");
+	childEnable("log_instant_messages_timestamp");
+	childEnable("log_chat_timestamp");
+	childEnable("log_chat_IM");
+	childEnable("log_date_timestamp");
 	
 	//RN: get wide string so replace char can work (requires fixed-width encoding)
 	LLWString busy_response = utf8str_to_wstring( gSavedPerAccountSettings.getString("BusyModeResponse") );
 	LLWString::replaceChar(busy_response, '^', '\n');
 	LLWString::replaceChar(busy_response, '%', ' ');
 	childSetText("busy_response", wstring_to_utf8str(busy_response));
 
 	enableHistory();
 
 	// Truncate the e-mail address if it's too long (to prevent going off
 	// the edge of the dialog).


More information about the SLDev mailing list