From 5ed4c7015641b0739291c7fc75b67aa5b0ed36fc Mon Sep 17 00:00:00 2001
From: Alexei Arabadji <aarabadji@productengine.com>
Date: Mon, 30 Nov 2009 19:59:44 +0200
Subject: [PATCH] =?UTF-8?q?implemented=20EXT-2962=20=E2=80=9CImplement=20a?=
 =?UTF-8?q?dding=20messages=20into=20IM=20history=20w/o=20spawning=20chicl?=
 =?UTF-8?q?et=E2=80=9D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

--HG--
branch : product-engine
---
 indra/newview/llimview.cpp                  |  8 +++++-
 indra/newview/llimview.h                    | 10 +++----
 indra/newview/llnotificationhandlerutil.cpp | 32 +++++++++------------
 3 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 827234be6e7..21a3ddfd781 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -455,7 +455,13 @@ bool LLIMModel::logToFile(const LLUUID& session_id, const std::string& from, con
 {
 	if (gSavedPerAccountSettings.getBOOL("LogInstantMessages"))
 	{
-		LLLogChat::saveHistory(LLIMModel::getInstance()->getName(session_id), from, from_id, utf8_text);
+		std::string name = LLIMModel::getInstance()->getName(session_id);
+		if (name == LLStringUtil::null)
+		{
+			name = from;
+		}
+
+		LLLogChat::saveHistory(name, from, from_id, utf8_text);
 		return true;
 	}
 	else
diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h
index 79b0acad69a..5cc0b033a2f 100644
--- a/indra/newview/llimview.h
+++ b/indra/newview/llimview.h
@@ -200,17 +200,17 @@ class LLIMModel :  public LLSingleton<LLIMModel>
 
 	void testMessages();
 
+	/**
+	 * Save an IM message into a file
+	 */
+	bool logToFile(const LLUUID& session_id, const std::string& from, const LLUUID& from_id, const std::string& utf8_text);
+
 private:
 	
 	/**
 	 * Add message to a list of message associated with session specified by session_id
 	 */
 	bool addToHistory(const LLUUID& session_id, const std::string& from, const LLUUID& from_id, const std::string& utf8_text); 
-
-	/**
-	 * Save an IM message into a file
-	 */
-	bool logToFile(const LLUUID& session_id, const std::string& from, const LLUUID& from_id, const std::string& utf8_text);
 };
 
 class LLIMSessionObserver
diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp
index 112d8295631..a30f896fa26 100644
--- a/indra/newview/llnotificationhandlerutil.cpp
+++ b/indra/newview/llnotificationhandlerutil.cpp
@@ -71,29 +71,23 @@ void LLHandlerUtil::logToIMP2P(const LLNotificationPtr& notification)
 		LLIMModel::LLIMSession* session = LLIMModel::instance().findIMSession(session_id);
 		if (session == NULL)
 		{
-			session_id = LLIMMgr::instance().addSession(name,
-					IM_NOTHING_SPECIAL, from_id);
-			session = LLIMModel::instance().findIMSession(session_id);
+			LLIMModel::instance().logToFile(session_id, name, from_id,
+					notification->getMessage());
 		}
-
-		if (session == NULL)
+		else
 		{
-			llerrs << "session " << session_id << "does not exist " << llendl;
-			return;
-		}
+			// store active session id
+			const LLUUID & active_session_id =
+					LLIMModel::instance().getActiveSessionID();
 
+			// set searched session as active to avoid IM toast popup
+			LLIMModel::instance().setActiveSessionID(session->mSessionID);
 
-		// store active session id
-		const LLUUID & active_session_id =
-				LLIMModel::instance().getActiveSessionID();
+			LLIMModel::instance().addMessage(session->mSessionID, name, from_id,
+					notification->getMessage());
 
-		// set created session as active to avoid IM toast popup
-		LLIMModel::instance().setActiveSessionID(session->mSessionID);
-
-		LLIMModel::instance().addMessage(session->mSessionID, name, from_id,
-				notification->getMessage());
-
-		// restore active session id
-		LLIMModel::instance().setActiveSessionID(active_session_id);
+			// restore active session id
+			LLIMModel::instance().setActiveSessionID(active_session_id);
+		}
 	}
 }
-- 
GitLab