diff options
author | James Cook <james@lindenlab.com> | 2010-02-23 16:34:02 -0800 |
---|---|---|
committer | James Cook <james@lindenlab.com> | 2010-02-23 16:34:02 -0800 |
commit | 67f3ed1844aabdb25abe1d52e651c076fec1eb9b (patch) | |
tree | da265743b56107a6baa1437f3cec02dae123c3a1 /indra | |
parent | 305ec89a70bf88fce8f5edda15047182bc56682b (diff) |
Prototype search by SLID and display name
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llfloateravatarpicker.cpp | 109 | ||||
-rw-r--r-- | indra/newview/llfloateravatarpicker.h | 1 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_avatar_picker.xml | 46 |
3 files changed, 130 insertions, 26 deletions
diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index cb549e65c8..63bced27d9 100644 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -36,14 +36,17 @@ // Viewer includes #include "llagent.h" #include "llcallingcard.h" +#include "lldateutil.h" // IDEVO #include "llfocusmgr.h" #include "llfloaterreg.h" #include "llviewercontrol.h" #include "llworld.h" // Linden libraries +#include "llavatarnamecache.h" // IDEVO #include "llbutton.h" #include "llcachename.h" +#include "llhttpclient.h" // IDEVO #include "lllineeditor.h" #include "llscrolllistctrl.h" #include "llscrolllistitem.h" @@ -339,23 +342,55 @@ BOOL LLFloaterAvatarPicker::visibleItemsSelected() const return FALSE; } -void LLFloaterAvatarPicker::find() +class LLAvatarPickerResponder : public LLHTTPClient::Responder { - std::string text = childGetValue("Edit").asString(); +public: + LLUUID mQueryID; - mQueryID.generate(); + LLAvatarPickerResponder(const LLUUID& id) : mQueryID(id) { } - LLMessageSystem* msg = gMessageSystem; + /*virtual*/ void result(const LLSD& content) + { + LLFloaterAvatarPicker* floater = + LLFloaterReg::findTypedInstance<LLFloaterAvatarPicker>("avatar_picker"); + if (floater) + { + floater->processResponse(mQueryID, content); + } + } - msg->newMessage("AvatarPickerRequest"); - msg->nextBlock("AgentData"); - msg->addUUID("AgentID", gAgent.getID()); - msg->addUUID("SessionID", gAgent.getSessionID()); - msg->addUUID("QueryID", mQueryID); // not used right now - msg->nextBlock("Data"); - msg->addString("Name", text); + /*virtual*/ void error(U32 status, const std::string& reason) + { + llinfos << "JAMESDEBUG avatar picker failed " << status + << " reason " << reason << llendl; + } +}; - gAgent.sendReliableMessage(); +void LLFloaterAvatarPicker::find() +{ + std::string text = childGetValue("Edit").asString(); + + mQueryID.generate(); + // IDEVO + if (LLAvatarNameCache::useDisplayNames()) + { + std::string url = "http://pdp15.lindenlab.com:8050/my-service/agent/search/"; + url += LLURI::escape(text); + url += "/"; + LLHTTPClient::get(url, new LLAvatarPickerResponder(mQueryID)); + } + else + { + LLMessageSystem* msg = gMessageSystem; + msg->newMessage("AvatarPickerRequest"); + msg->nextBlock("AgentData"); + msg->addUUID("AgentID", gAgent.getID()); + msg->addUUID("SessionID", gAgent.getSessionID()); + msg->addUUID("QueryID", mQueryID); // not used right now + msg->nextBlock("Data"); + msg->addString("Name", text); + gAgent.sendReliableMessage(); + } getChild<LLScrollListCtrl>("SearchResults")->deleteAllItems(); getChild<LLScrollListCtrl>("SearchResults")->setCommentText(getString("searching")); @@ -427,6 +462,7 @@ void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void* } LLSD element; element["id"] = avatar_id; // value + element["columns"][0]["column"] = "name"; element["columns"][0]["value"] = avatar_name; search_results->addElement(element); } @@ -440,6 +476,55 @@ void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void* } } +void LLFloaterAvatarPicker::processResponse(const LLUUID& query_id, const LLSD& content) +{ + // Check for out-of-date query + if (query_id != mQueryID) return; + + LLScrollListCtrl* search_results = getChild<LLScrollListCtrl>("SearchResults"); + + if (content.size() == 0) + { + LLStringUtil::format_map_t map; + map["[TEXT]"] = childGetText("Edit"); + LLSD item; + item["id"] = LLUUID::null; + item["columns"][0]["column"] = "name"; + item["columns"][0]["value"] = getString("not_found", map); + search_results->addElement(item); + search_results->setEnabled(FALSE); + childDisable("ok_btn"); + return; + } + + // clear "Searching" label on first results + search_results->deleteAllItems(); + + LLSD item; + LLSD::array_const_iterator it = content.beginArray(); + for ( ; it != content.endArray(); ++it) + { + const LLSD& row = *it; + item["id"] = row["agent_id"]; + LLSD& columns = item["columns"]; + 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[2]["column"] = "age"; + columns[2]["value"] = LLDateUtil::ageFromDateISO(born_on); + columns[3]["column"] = "profile"; + columns[3]["value"] = row["profile"]; + search_results->addElement(item); + } + + childEnable("ok_btn"); + search_results->selectFirstItem(); + onList(); + search_results->setFocus(TRUE); +} + //static void LLFloaterAvatarPicker::editKeystroke(LLLineEditor* caller, void* user_data) { diff --git a/indra/newview/llfloateravatarpicker.h b/indra/newview/llfloateravatarpicker.h index e35466cec8..bae43d3211 100644 --- a/indra/newview/llfloateravatarpicker.h +++ b/indra/newview/llfloateravatarpicker.h @@ -58,6 +58,7 @@ public: void setOkBtnEnableCb(validate_callback_t cb); static void processAvatarPickerReply(class LLMessageSystem* msg, void**); + void processResponse(const LLUUID& query_id, const LLSD& content); private: void editKeystroke(class LLLineEditor* caller, void* user_data); 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 f59badfcb4..59923bec96 100644 --- a/indra/newview/skins/default/xui/en/floater_avatar_picker.xml +++ b/indra/newview/skins/default/xui/en/floater_avatar_picker.xml @@ -5,11 +5,11 @@ height="350" layout="topleft" min_height="200" - min_width="265" + min_width="400" name="avatarpicker" help_topic="avatarpicker" title="CHOOSE RESIDENT" - width="265"> + width="500"> <floater.string name="not_found"> '[TEXT]' not found @@ -40,7 +40,7 @@ name="ResidentChooserTabs" tab_position="top" top="20" - width="265"> + width="500"> <panel border="none" height="150" @@ -83,14 +83,32 @@ left_pad="5" name="Find" width="45" /> - <scroll_list - follows="all" - height="98" - layout="topleft" - left="0" - name="SearchResults" - top="52" - width="132" /> + <scroll_list + draw_heading="true" + follows="all" + height="98" + layout="topleft" + left="0" + name="SearchResults" + top="52" + width="132"> + <columns + label="Name" + name="name" + width="100" /> + <columns + label="SL ID" + name="slid" + width="100" /> + <columns + label="Age" + name="age" + width="100" /> + <columns + label="Profile" + name="profile" + width="100" /> + </scroll_list> </panel> <panel border="none" @@ -207,16 +225,16 @@ </panel> </tab_container> <button - follows="right|bottom" + follows="left|bottom" height="23" label="OK" label_selected="OK" name="ok_btn" top_pad="3" - left="46" + left="10" width="100" /> <button - follows="right|bottom" + follows="left|bottom" height="23" label="Cancel" label_selected="Cancel" |