From 6575b685e91d334198789c88dec2efab7e5a1ac9 Mon Sep 17 00:00:00 2001
From: Igor Borovkov <iborovkov@productengine.com>
Date: Wed, 24 Feb 2010 17:18:05 +0200
Subject: [PATCH] fixed EXT-5526 Objects are shown as persons in the chat
 history from previous sessions

- new chat source type CHAT_SOURCE_UNKNOWN for avatar names not in cache and object names consisting of two words (avatar names like)
- new icon (unknown_icon.png) for message headers () of nearby chat messagses coming from CHAT_SOURCE_UNKNOWN
- context menu no longer displayed for object names from chat history (no UUIDs)
- double click on message headers in nearby chat no longer opens Inspector (no UUIDs)
- object names (loaded from chat history) in nearby chat are no longer SLURLed (no UUIDs for them)

--HG--
branch : product-engine
---
 indra/llcommon/llchat.h                       |   3 ++-
 indra/newview/llchathistory.cpp               |  11 +++++++---
 indra/newview/llnearbychat.cpp                |  19 ++++++++++++++++++
 .../default/textures/icons/unknown_icon.png   | Bin 0 -> 884 bytes
 .../skins/default/textures/textures.xml       |   1 +
 5 files changed, 30 insertions(+), 4 deletions(-)
 create mode 100644 indra/newview/skins/default/textures/icons/unknown_icon.png

diff --git a/indra/llcommon/llchat.h b/indra/llcommon/llchat.h
index 52238d4533f..f1b9091298f 100644
--- a/indra/llcommon/llchat.h
+++ b/indra/llcommon/llchat.h
@@ -43,7 +43,8 @@ typedef enum e_chat_source_type
 {
 	CHAT_SOURCE_SYSTEM = 0,
 	CHAT_SOURCE_AGENT = 1,
-	CHAT_SOURCE_OBJECT = 2
+	CHAT_SOURCE_OBJECT = 2,
+	CHAT_SOURCE_UNKNOWN = 3
 } EChatSourceType;
 
 typedef enum e_chat_type
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index 5e8d5a63d0a..45c2d26fdea 100644
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -209,6 +209,8 @@ class LLChatHistoryHeader: public LLPanel
 
 	void showInspector()
 	{
+		if (mAvatarID.isNull() && CHAT_SOURCE_SYSTEM != mSourceType) return;
+		
 		if (mSourceType == CHAT_SOURCE_OBJECT)
 		{
 			LLFloaterReg::showInstance("inspect_object", LLSD().with("object_id", mAvatarID));
@@ -279,6 +281,9 @@ class LLChatHistoryHeader: public LLPanel
 				break;
 			case CHAT_SOURCE_SYSTEM:
 				icon->setValue(LLSD("SL_Logo"));
+				break;
+			case CHAT_SOURCE_UNKNOWN: 
+				icon->setValue(LLSD("Unknown_Icon"));
 		}
 	}
 
@@ -325,9 +330,9 @@ class LLChatHistoryHeader: public LLPanel
 	{
 		if(mSourceType == CHAT_SOURCE_SYSTEM)
 			showSystemContextMenu(x,y);
-		if(mSourceType == CHAT_SOURCE_AGENT)
+		if(mAvatarID.notNull() && mSourceType == CHAT_SOURCE_AGENT)
 			showAvatarContextMenu(x,y);
-		if(mSourceType == CHAT_SOURCE_OBJECT && SYSTEM_FROM != mFrom)
+		if(mAvatarID.notNull() && mSourceType == CHAT_SOURCE_OBJECT && SYSTEM_FROM != mFrom)
 			showObjectContextMenu(x,y);
 	}
 
@@ -632,7 +637,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
 		if (utf8str_trim(chat.mFromName).size() != 0)
 		{
 			// Don't hotlink any messages from the system (e.g. "Second Life:"), so just add those in plain text.
-			if ( chat.mSourceType == CHAT_SOURCE_OBJECT )
+			if ( chat.mSourceType == CHAT_SOURCE_OBJECT && chat.mFromID.notNull())
 			{
 				// for object IMs, create a secondlife:///app/objectim SLapp
 				std::string url = LLSLURL::buildCommand("objectim", chat.mFromID, "");
diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp
index 16384ef6e0c..c8d5d782b74 100644
--- a/indra/newview/llnearbychat.cpp
+++ b/indra/newview/llnearbychat.cpp
@@ -278,6 +278,13 @@ void LLNearbyChat::processChatHistoryStyleUpdate(const LLSD& newvalue)
 		nearby_chat->updateChatHistoryStyle();
 }
 
+bool isTwoWordsName(const std::string& name)
+{
+	//checking for a single space
+	S32 pos = name.find(' ', 0);
+	return std::string::npos != pos && name.rfind(' ', name.length()) == pos && 0 != pos && name.length()-1 != pos;
+}
+
 void LLNearbyChat::loadHistory()
 {
 	LLSD do_not_log;
@@ -304,6 +311,18 @@ void LLNearbyChat::loadHistory()
 		chat.mText = msg[IM_TEXT].asString();
 		chat.mTimeStr = msg[IM_TIME].asString();
 		chat.mChatStyle = CHAT_STYLE_HISTORY;
+
+		chat.mSourceType = CHAT_SOURCE_AGENT;
+		if (from_id.isNull() && SYSTEM_FROM == from)
+		{	
+			chat.mSourceType = CHAT_SOURCE_SYSTEM;
+			
+		}
+		else if (from_id.isNull())
+		{
+			chat.mSourceType = isTwoWordsName(from) ? CHAT_SOURCE_UNKNOWN : CHAT_SOURCE_OBJECT;
+		}
+
 		addMessage(chat, true, do_not_log);
 
 		it++;
diff --git a/indra/newview/skins/default/textures/icons/unknown_icon.png b/indra/newview/skins/default/textures/icons/unknown_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..8441d86596deea6b473ec6835f2768bdd09884bc
GIT binary patch
literal 884
zcmV-)1B?8LP)<h;3K|Lk000e1NJLTq000sI000sQ0ssI2*{m4=0000PbVXQnQ*UN;
zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU#7D+@wRCwBCQ{PXLQ5gQd^PTTQGnNR5
zk{|;CQ7&rP%2q6fKh~V9mYb`*p+<A-qSZgpyzIVtk@ME8=2mWQC2qRZ&5N2-#0Hq@
z5Re~=5CY%NUceYz&-Q)i?40*G@B2LGyrj$JBFYd&k>`1(Qfaf<tQK>tMuSM=D3Sab
z2yAcrlgT7iMkN?m1|Y~}vcbW@fq?<5v7INWgOkD^R?yq=@X)<TG&VQ?WpUA4C=@Wp
z=QQBR<#M;%?Q}Y26geMAy<3a>j#&=YF>$L^HgTur<+#UcwM<V>r_*VgrYVEL0E5Tl
z>Fev`d9J|nPv#D`Ls5Jd<0Mp&m|%)q3PqjG(v9mqjS9ua#s;K8@PRzYQ!ExSAqCQW
zEE*dXRzCEIlh=6t1%aSZFpEE}`wO|O!{GoGB^r1Dvx+4Mk%=7FBkVmNa@>D3@?!X|
z%cLMUfj}spNU|&|Nm74*e{*v)2H$i#9mjFN%yUw23uAbETd8T~ST;*a{u7?S44pkN
zw;_tDgD|aDYq#5x*=z=Fa7@`z2`p|mcGTC`H(+w|dt&{tNEA=+iGF8q4~ZzK2m*kD
zA>%(znFq!SLIaJy{>r@lmZCF}VQKUAh)ZWQgQSWUl}d$)|3D$~IM2UXiqo;3XP5Ro
zqYv9m7NN|k0w)p)k|b-F;Of>A?C#$FxP14OdrYO(ff?0ZgitD#LZMIyvez<sk!ZPy
zFEhofHnUoL?p6g5CI|vhu;1?whr@ckzIr4ph+WFM=?9iZikC#ORymj#jYfSwAA&c!
zu&_XuQQ51*=;O}u#1HX(fIK`p0;$zhP@&iBjm2V=$z<B!-v>WCIy#^Lh{^Nf*yrEd
zk+aP>M@D^)P936UK!aOZU0t1-nJI+<^7%Zx(dFf3hGA%$fo#@BOpu6RPjitymKR_h
z`eS8fWol|Fm&=v<$7nRdADHk)v)Qa#tyVTE9J&VTG<<~(KJCBRZZbzAk=fZ<$dk!r
zKwhcfYMTmWXf&Gc?(VKmYm>a8$P3v#8wdt`TU#YPHEsG=fB^uL)sh=XcYnkH0000<
KMNUMnLSTaKnV+cu

literal 0
HcmV?d00001

diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml
index f200566c0e2..4768cf14fb2 100644
--- a/indra/newview/skins/default/textures/textures.xml
+++ b/indra/newview/skins/default/textures/textures.xml
@@ -516,6 +516,7 @@ with the same filename but different name
 
   <texture name="SL_Logo" file_name="icons/SL_Logo.png" preload="true" />
   <texture name="OBJECT_Icon" file_name="icons/object_icon.png" preload="true" />
+  <texture name="Unknown_Icon" file_name="icons/unknown_icon.png" preload="true" />
 
   <texture name="Snapshot_Off" file_name="bottomtray/Snapshot_Off.png" preload="true" scale.left="4" scale.top="19" scale.right="22" scale.bottom="4" />
   <texture name="Snapshot_Over" file_name="bottomtray/Snapshot_Over.png" preload="false" />
-- 
GitLab