From 6d1e44b0338dd2815f605a5ba6e6528932cf3ebc Mon Sep 17 00:00:00 2001
From: James Cook <james@lindenlab.com>
Date: Tue, 20 Apr 2010 14:52:09 -0700
Subject: Avatar picker requests are routed via sim capability

---
 indra/newview/lldateutil.cpp                       |  5 +++
 indra/newview/lldateutil.h                         |  2 +
 indra/newview/llfloateravatarpicker.cpp            | 44 +++++++++++++++-------
 indra/newview/llviewerregion.cpp                   |  1 +
 .../skins/default/xui/en/floater_avatar_picker.xml |  4 --
 5 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/indra/newview/lldateutil.cpp b/indra/newview/lldateutil.cpp
index 150edb5bf8..1a13cd05fd 100644
--- a/indra/newview/lldateutil.cpp
+++ b/indra/newview/lldateutil.cpp
@@ -180,3 +180,8 @@ std::string LLDateUtil::ageFromDateISO(const std::string& date_string)
 {
 	return ageFromDateISO(date_string, LLDate::now());
 }
+
+std::string LLDateUtil::ageFromDate(S32 year, S32 month, S32 day)
+{
+	return age_from_date(year, month, day, LLDate::now());
+}
diff --git a/indra/newview/lldateutil.h b/indra/newview/lldateutil.h
index d077f4eefb..9c62241fe6 100644
--- a/indra/newview/lldateutil.h
+++ b/indra/newview/lldateutil.h
@@ -50,6 +50,8 @@ namespace LLDateUtil
 
 	// Calls the above with LLDate::now()
 	std::string ageFromDateISO(const std::string& date_string);
+
+	std::string ageFromDate(S32 year, S32 month, S32 day);
 }
 
 #endif
diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp
index ed458a4b02..06070f876d 100644
--- a/indra/newview/llfloateravatarpicker.cpp
+++ b/indra/newview/llfloateravatarpicker.cpp
@@ -36,10 +36,12 @@
 // Viewer includes
 #include "llagent.h"
 #include "llcallingcard.h"
-#include "lldateutil.h"			// IDEVO
+#include "lldate.h"				// split()
+#include "lldateutil.h"			// ageFromDate()
 #include "llfocusmgr.h"
 #include "llfloaterreg.h"
 #include "llviewercontrol.h"
+#include "llviewerregion.h"		// getCapability()
 #include "llworld.h"
 
 // Linden libraries
@@ -371,12 +373,26 @@ void LLFloaterAvatarPicker::find()
 	std::string text = childGetValue("Edit").asString();
 
 	mQueryID.generate();
-	// IDEVO
-	if (LLAvatarNameCache::useDisplayNames())
+
+	std::string url;
+	url.reserve(128); // avoid a memory allocation or two
+
+	LLViewerRegion* region = gAgent.getRegion();
+	url = region->getCapability("AvatarPickerSearch");
+	// Prefer use of capabilities to search on both SLID and display name
+	// but allow display name search to be manually turned off for test
+	if (!url.empty()
+		&& LLAvatarNameCache::useDisplayNames())
 	{
-		std::string url = "http://pdp15.lindenlab.com:8050/my-service/agent/search/";
+		// capability urls don't end in '/', but we need one to parse
+		// query parameters correctly
+		if (url.size() > 0 && url[url.size()-1] != '/')
+		{
+			url += "/";
+		}
+		url += "?name=";
 		url += LLURI::escape(text);
-		url += "/";
+		llinfos << "JAMESDEBUG picker " << url << llendl;
 		LLHTTPClient::get(url, new LLAvatarPickerResponder(mQueryID));
 	}
 	else
@@ -483,7 +499,8 @@ void LLFloaterAvatarPicker::processResponse(const LLUUID& query_id, const LLSD&
 
 	LLScrollListCtrl* search_results = getChild<LLScrollListCtrl>("SearchResults");
 
-	if (content.size() == 0)
+	LLSD agents = content["agents"];
+	if (agents.size() == 0)
 	{
 		LLStringUtil::format_map_t map;
 		map["[TEXT]"] = childGetText("Edit");
@@ -501,8 +518,8 @@ void LLFloaterAvatarPicker::processResponse(const LLUUID& query_id, const LLSD&
 	search_results->deleteAllItems();
 
 	LLSD item;
-	LLSD::array_const_iterator it = content.beginArray();
-	for ( ; it != content.endArray(); ++it)
+	LLSD::array_const_iterator it = agents.beginArray();
+	for ( ; it != agents.endArray(); ++it)
 	{
 		const LLSD& row = *it;
 		item["id"] = row["agent_id"];
@@ -510,12 +527,13 @@ void LLFloaterAvatarPicker::processResponse(const LLUUID& query_id, const LLSD&
 		columns[0]["column"] = "name";
 		columns[0]["value"] = row["display_name"];
 		columns[1]["column"] = "slid";
-		columns[1]["value"] = row["slid"];
-		std::string born_on = row["born_on"].asString();
+		columns[1]["value"] = row["sl_id"];
+		LLDate account_created = row["account_created"].asDate();
+		S32 year, month, day;
+		account_created.split(&year, &month, &day);
+		std::string age = LLDateUtil::ageFromDate(year, month, day);
 		columns[2]["column"] = "age";
-		columns[2]["value"] = LLDateUtil::ageFromDateISO(born_on);
-		columns[3]["column"] = "profile";
-		columns[3]["value"] = row["profile"];
+		columns[2]["value"] = age;
 		search_results->addElement(item);
 	}
 
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 83c5760b58..502fc87e41 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1466,6 +1466,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
 	LLSD capabilityNames = LLSD::emptyArray();
 	
 	capabilityNames.append("AttachmentResources");
+	capabilityNames.append("AvatarPickerSearch");
 	capabilityNames.append("ChatSessionRequest");
 	capabilityNames.append("CopyInventoryFromNotecard");
 	capabilityNames.append("DispatchRegionInfo");
diff --git a/indra/newview/skins/default/xui/en/floater_avatar_picker.xml b/indra/newview/skins/default/xui/en/floater_avatar_picker.xml
index 59923bec96..489b7c0536 100644
--- a/indra/newview/skins/default/xui/en/floater_avatar_picker.xml
+++ b/indra/newview/skins/default/xui/en/floater_avatar_picker.xml
@@ -104,10 +104,6 @@
               label="Age"
               name="age"
               width="100" />
-            <columns
-              label="Profile"
-              name="profile"
-              width="100" />
           </scroll_list>
         </panel>
         <panel
-- 
cgit v1.2.3