summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llmessage/llexperiencecache.cpp46
-rw-r--r--indra/llmessage/llexperiencecache.h5
-rw-r--r--indra/newview/llpanelexperiencepicker.cpp67
-rw-r--r--indra/newview/llpanelexperiencepicker.h3
4 files changed, 67 insertions, 54 deletions
diff --git a/indra/llmessage/llexperiencecache.cpp b/indra/llmessage/llexperiencecache.cpp
index b65a3c59d5..29ca0b2820 100644
--- a/indra/llmessage/llexperiencecache.cpp
+++ b/indra/llmessage/llexperiencecache.cpp
@@ -84,6 +84,7 @@ const int LLExperienceCache::PROPERTY_SUSPENDED = 1 << 7;
// default values
const F64 LLExperienceCache::DEFAULT_EXPIRATION = 600.0;
const S32 LLExperienceCache::DEFAULT_QUOTA = 128; // this is megabytes
+const int LLExperienceCache::SEARCH_PAGE_SIZE = 30;
//=========================================================================
LLExperienceCache::LLExperienceCache():
@@ -549,8 +550,8 @@ void LLExperienceCache::fetchAssociatedExperience(const LLUUID& objectId, const
void LLExperienceCache::fetchAssociatedExperienceCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, LLUUID objectId, LLUUID itemId, ExperienceGetFn_t fn)
{
LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest());
-
std::string url = mCapability("GetMetadata");
+
if (url.empty())
{
LL_WARNS("ExperienceCache") << "No Metadata capability." << LL_ENDL;
@@ -591,6 +592,49 @@ void LLExperienceCache::fetchAssociatedExperienceCoro(LLCoreHttpUtil::HttpCorout
get(expId, fn);
}
+//-------------------------------------------------------------------------
+void LLExperienceCache::findExperienceByName(const std::string text, int page, ExperienceGetFn_t fn)
+{
+ if (mCapability.empty())
+ {
+ LL_WARNS("ExperienceCache") << "Capability query method not set." << LL_ENDL;
+ return;
+ }
+
+ LLCoprocedureManager::getInstance()->enqueueCoprocedure("ExpCache", "Search Name",
+ boost::bind(&LLExperienceCache::findExperienceByNameCoro, this, _1, text, page, fn));
+}
+
+void LLExperienceCache::findExperienceByNameCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, std::string text, int page, ExperienceGetFn_t fn)
+{
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest());
+ std::ostringstream url;
+
+
+ url << mCapability("FindExperienceByName") << "?page=" << page << "&page_size=" << SEARCH_PAGE_SIZE << "&query=" << LLURI::escape(text);
+
+ LLSD result = httpAdapter->getAndYield(httpRequest, url.str());
+
+ LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+ if (!status)
+ {
+ fn(LLSD());
+ return;
+ }
+
+ result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS);
+
+ const LLSD& experiences = result["experience_keys"];
+ for (LLSD::array_const_iterator it = experiences.beginArray(); it != experiences.endArray(); ++it)
+ {
+ insert(*it);
+ }
+
+ fn(result);
+}
+
//=========================================================================
void LLExperienceCacheImpl::mapKeys(const LLSD& legacyKeys)
{
diff --git a/indra/llmessage/llexperiencecache.h b/indra/llmessage/llexperiencecache.h
index d1222933df..f6f69d92ba 100644
--- a/indra/llmessage/llexperiencecache.h
+++ b/indra/llmessage/llexperiencecache.h
@@ -64,6 +64,7 @@ public:
//-------------------------------------------
void fetchAssociatedExperience(const LLUUID& objectId, const LLUUID& itemId, ExperienceGetFn_t fn);
+ void findExperienceByName(const std::string text, int page, ExperienceGetFn_t fn);
//-------------------------------------------
static const std::string NAME; // "name"
@@ -113,6 +114,7 @@ private:
// default values
static const F64 DEFAULT_EXPIRATION; // 600.0
static const S32 DEFAULT_QUOTA; // 128 this is megabytes
+ static const int SEARCH_PAGE_SIZE;
//--------------------------------------------
void processExperience(const LLUUID& public_key, const LLSD& experience);
@@ -133,7 +135,8 @@ private:
void requestExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &, std::string, RequestQueue_t);
void requestExperiences();
- void fetchAssociatedExperienceCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &, LLUUID objectId, LLUUID itemId, ExperienceGetFn_t fn);
+ void fetchAssociatedExperienceCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &, LLUUID, LLUUID, ExperienceGetFn_t);
+ void findExperienceByNameCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &, std::string, int, ExperienceGetFn_t);
void bootstrap(const LLSD& legacyKeys, int initialExpiration);
void exportFile(std::ostream& ostr) const;
diff --git a/indra/newview/llpanelexperiencepicker.cpp b/indra/newview/llpanelexperiencepicker.cpp
index 7c19e32e7e..db846ffad9 100644
--- a/indra/newview/llpanelexperiencepicker.cpp
+++ b/indra/newview/llpanelexperiencepicker.cpp
@@ -59,41 +59,6 @@ const static std::string columnSpace = " ";
static LLPanelInjector<LLPanelExperiencePicker> t_panel_status("llpanelexperiencepicker");
-class LLExperienceSearchResponder : public LLHTTPClient::Responder
-{
-public:
- LLUUID mQueryID;
- LLHandle<LLPanelExperiencePicker> mParent;
-
- LLExperienceSearchResponder(const LLUUID& id, const LLHandle<LLPanelExperiencePicker>& parent) : mQueryID(id), mParent(parent) { }
-
-protected:
- /*virtual*/ void httpSuccess()
- {
- if(mParent.isDead())
- return;
-
- LLPanelExperiencePicker* panel =mParent.get();
- if (panel)
- {
- panel->processResponse(mQueryID, getContent());
- }
- }
-
- /*virtual*/ void httpFailure()
- {
- if(mParent.isDead())
- return;
-
- LLPanelExperiencePicker* panel =mParent.get();
- if (panel)
- {
- panel->processResponse(mQueryID, LLSD());
- }
- LL_WARNS() << "experience picker failed [status:" << getStatus() << "]: " << getContent() << LL_ENDL;
- }
-};
-
LLPanelExperiencePicker::LLPanelExperiencePicker()
:LLPanel()
{
@@ -164,17 +129,11 @@ void LLPanelExperiencePicker::find()
{
std::string text = getChild<LLUICtrl>(TEXT_EDIT)->getValue().asString();
mQueryID.generate();
- std::ostringstream url;
- LLViewerRegion* region = gAgent.getRegion();
- std::string cap = region->getCapability("FindExperienceByName");
- if (!cap.empty())
- {
- url << cap << "?page=" << mCurrentPage << "&page_size=30&query=" << LLURI::escape(text);
- LLHTTPClient::get(url.str(), new LLExperienceSearchResponder(mQueryID, getDerivedHandle<LLPanelExperiencePicker>()));
+ LLExperienceCache::getInstance()->findExperienceByName(text, mCurrentPage,
+ boost::bind(&LLPanelExperiencePicker::findResults, getDerivedHandle<LLPanelExperiencePicker>(), mQueryID, _1));
- }
- getChild<LLScrollListCtrl>(LIST_RESULTS)->deleteAllItems();
+ getChild<LLScrollListCtrl>(LIST_RESULTS)->deleteAllItems();
getChild<LLScrollListCtrl>(LIST_RESULTS)->setCommentText(getString("searching"));
getChildView(BTN_OK)->setEnabled(FALSE);
@@ -184,6 +143,19 @@ void LLPanelExperiencePicker::find()
getChildView(BTN_LEFT)->setEnabled(FALSE);
}
+/*static*/
+void LLPanelExperiencePicker::findResults(LLHandle<LLPanelExperiencePicker> hparent, LLUUID queryId, LLSD foundResult)
+{
+ if (hparent.isDead())
+ return;
+
+ LLPanelExperiencePicker* panel = hparent.get();
+ if (panel)
+ {
+ panel->processResponse(queryId, foundResult);
+ }
+}
+
bool LLPanelExperiencePicker::isSelectButtonEnabled()
{
@@ -234,13 +206,6 @@ void LLPanelExperiencePicker::processResponse( const LLUUID& query_id, const LLS
mResponse = content;
- const LLSD& experiences=mResponse["experience_keys"];
- LLSD::array_const_iterator it = experiences.beginArray();
- for ( ; it != experiences.endArray(); ++it)
- {
- LLExperienceCache::getInstance()->insert(*it);
- }
-
getChildView(BTN_RIGHT)->setEnabled(content.has("next_page_url"));
getChildView(BTN_LEFT)->setEnabled(content.has("previous_page_url"));
diff --git a/indra/newview/llpanelexperiencepicker.h b/indra/newview/llpanelexperiencepicker.h
index e39ffed70b..97aa04cf4c 100644
--- a/indra/newview/llpanelexperiencepicker.h
+++ b/indra/newview/llpanelexperiencepicker.h
@@ -74,8 +74,9 @@ private:
void getSelectedExperienceIds( const LLScrollListCtrl* results, uuid_vec_t &experience_ids );
void setAllowMultiple(bool allow_multiple);
-
void find();
+ static void findResults(LLHandle<LLPanelExperiencePicker> hparent, LLUUID queryId, LLSD foundResult);
+
bool isSelectButtonEnabled();
void processResponse( const LLUUID& query_id, const LLSD& content );