From abf5d5b36083d4f1d94674e456750838ae683157 Mon Sep 17 00:00:00 2001
From: andreykproductengine <akleshchev@productengine.com>
Date: Fri, 14 Mar 2014 21:15:18 +0200
Subject: MAINT-3426 FIXED Searching inventory for "online" no longer returns
 online friends calling cards in search results.

---
 indra/newview/llinventorybridge.cpp | 42 +++++++++++++++++++++++++++++++++++++
 indra/newview/llinventorybridge.h   |  1 +
 2 files changed, 43 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 44943d8722..101b16b027 100755
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -4708,6 +4708,10 @@ public:
 	virtual void changed(U32 mask)
 	{
 		mBridgep->refreshFolderViewItem();
+		if (mask & LLFriendObserver::ONLINE)
+		{
+			mBridgep->checkSearchBySuffixChanges();
+		}
 	}
 protected:
 	LLCallingCardBridge* mBridgep;
@@ -4742,6 +4746,44 @@ void LLCallingCardBridge::refreshFolderViewItem()
 	}
 }
 
+void LLCallingCardBridge::checkSearchBySuffixChanges()
+{
+	if (!mDisplayName.empty())
+	{
+		// changes in mDisplayName are processed by rename function and here it will be always same
+		// suffixes are also of fixed length, and we are processing change of one at a time,
+		// so it should be safe to use length (note: mSearchableName is capitalized)
+		S32 old_length = mSearchableName.length();
+		S32 new_length = mDisplayName.length() + getLabelSuffix().length();
+		if (old_length == new_length)
+		{
+			return;
+		}
+		mSearchableName.assign(mDisplayName);
+		mSearchableName.append(getLabelSuffix());
+		LLStringUtil::toUpper(mSearchableName);
+		if (new_length<old_length)
+		{
+			LLInventoryFilter* filter = getInventoryFilter();
+			if (filter && mPassedFilter && mSearchableName.find(filter->getFilterSubString()) == std::string::npos)
+			{
+				// string no longer contains substring 
+				// we either have to update all parents manually or restart filter.
+				// dirtyFilter will not work here due to obsolete descendants' generations 
+				getInventoryFilter()->setModified(LLFolderViewFilter::FILTER_MORE_RESTRICTIVE);
+			}
+		}
+		else
+		{
+			if (getInventoryFilter())
+			{
+				// mSearchableName became longer, we gained additional suffix and need to repeat filter check.
+				dirtyFilter();
+			}
+		}
+	}
+}
+
 // virtual
 void LLCallingCardBridge::performAction(LLInventoryModel* model, std::string action)
 {
diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h
index bc875e8f37..b29235260b 100755
--- a/indra/newview/llinventorybridge.h
+++ b/indra/newview/llinventorybridge.h
@@ -419,6 +419,7 @@ public:
 							void* cargo_data,
 							std::string& tooltip_msg);
 	void refreshFolderViewItem();
+	void checkSearchBySuffixChanges();
 protected:
 	LLCallingCardObserver* mObserver;
 };
-- 
cgit v1.2.3