From 3781615afa6db7289f26f404885ac614c7f1cee0 Mon Sep 17 00:00:00 2001
From: mberezhnoy <mberezhnoy@productengine.com>
Date: Wed, 6 Feb 2013 10:03:42 +0200
Subject: [PATCH] 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 --
 .../xui/en/floater_conversation_log.xml       |  3 ---
 .../newview/skins/default/xui/en/strings.xml  | 11 +++++++++
 7 files changed, 42 insertions(+), 17 deletions(-)

diff --git a/indra/newview/llconversationlog.cpp b/indra/newview/llconversationlog.cpp
index 7bd6ef8cd7b..5f037549aba 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 65a18c02e5d..d5b6eccb294 100644
--- a/indra/newview/llconversationlog.h
+++ b/indra/newview/llconversationlog.h
@@ -141,6 +141,9 @@ class LLConversationLog : public LLSingleton<LLConversationLog>, LLIMSessionObse
 	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 @@ class LLConversationLog : public LLSingleton<LLConversationLog>, LLIMSessionObse
 
 	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 6dbcb7bef78..96b225b841a 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<LLConversationLogList> 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<LLConversation>& conversations = LLConversationLog::instance().getConversations();
+	const std::vector<LLConversation>& conversations = log_instance.getConversations();
 	std::vector<LLConversation>::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 07723ce44df..4c910c56555 100644
--- a/indra/newview/llfloaterconversationlog.cpp
+++ b/indra/newview/llfloaterconversationlog.cpp
@@ -63,10 +63,6 @@ BOOL LLFloaterConversationLog::postBuild()
 
 	getChild<LLFilterEditor>("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 aa0f480aae6..e971330f3d0 100644
--- a/indra/newview/llfloaterconversationlog.h
+++ b/indra/newview/llfloaterconversationlog.h
@@ -49,8 +49,6 @@ class LLFloaterConversationLog : public LLFloater
 	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 256e03c4d7d..7229292a147 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">
-  <string name="logging_calls_disabled">
-     Conversations are not being logged. To log conversations in the future, select "Save IM logs on my computer" under Preferences > Privacy.
-  </string>
   <panel
    follows="left|top|right"
    height="32"
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index d6a2383e52e..5aa743b32d2 100644
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -3908,4 +3908,15 @@ Try enclosing path to the editor with double quotes.
   <!-- Spell check settings floater -->
   <string name="UserDictionary">[User]</string>
   
+  <!-- Conversation log messages -->
+  <string name="logging_calls_disabled_log_empty">
+    Conversations are not being logged. To begin keeping a log, choose "Save: Log only" or "Save: Log and transcripts" under Preferences > Chat.
+  </string>
+  <string name="logging_calls_disabled_log_not_empty">
+    No more conversations will be logged. To resume keeping a log, choose "Save: Log only" or "Save: Log and transcripts" under Preferences > Chat.
+  </string>
+  <string name="logging_calls_enabled_log_empty">
+    There are no logged conversations. After you contact someone, or someone contacts you, a log entry will be shown here.
+  </string>
+  
   </strings>
-- 
GitLab