diff options
author | Rider Linden <none@none> | 2015-04-01 16:37:00 -0700 |
---|---|---|
committer | Rider Linden <none@none> | 2015-04-01 16:37:00 -0700 |
commit | edc1439bd633bdac183fbecc131edd55074b5442 (patch) | |
tree | 4655e22fd1777c5d5c44e585e755aad4676deb7b /indra/newview | |
parent | 0b02b36b651987d5d24c225fa9472e0d35803559 (diff) |
Added AvatarNameCache as coroutine, with LLCore::HttpHandler to respond correctly to Event Pumps.
Added get/setRequestURL() to LLCore::HttpResponse
Removed URI from the HttpSDHandler.
Diffstat (limited to 'indra/newview')
-rwxr-xr-x | indra/newview/llagent.cpp | 55 | ||||
-rwxr-xr-x | indra/newview/llagent.h | 10 | ||||
-rwxr-xr-x | indra/newview/llappearancemgr.cpp | 8 | ||||
-rwxr-xr-x | indra/newview/llmaterialmgr.cpp | 14 |
4 files changed, 54 insertions, 33 deletions
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 667d530e39..eeedda5c6d 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -325,7 +325,6 @@ bool LLAgent::isMicrophoneOn(const LLSD& sdname) // For a toggled version, see viewer.h for the // TOGGLE_HACKED_GODLIKE_VIEWER define, instead. // ************************************************************ -bool LLAgent::mActive = true; // Constructors and Destructors @@ -474,7 +473,9 @@ void LLAgent::init() mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AGENT); - doOnIdleRepeating(boost::bind(&LLAgent::onIdle, this)); + // Now ensure that we get regular callbacks to poll for completion. + mBoundListener = LLEventPumps::instance().obtain("mainloop"). + listen(LLEventPump::inventName(), boost::bind(&LLAgent::pollHttp, this, _1)); mInitialized = TRUE; } @@ -484,7 +485,6 @@ void LLAgent::init() //----------------------------------------------------------------------------- void LLAgent::cleanup() { - mActive = false; mRegionp = NULL; if (mTeleportFinishedSlot.connected()) { @@ -494,6 +494,10 @@ void LLAgent::cleanup() { mTeleportFailedSlot.disconnect(); } + if (mBoundListener.connected()) + { + mBoundListener.disconnect(); + } } //----------------------------------------------------------------------------- @@ -517,16 +521,16 @@ LLAgent::~LLAgent() } //----------------------------------------------------------------------------- -// Idle processing +// pollHttp +// Polling done once per frame on the "mainloop" to support HTTP processing. //----------------------------------------------------------------------------- -bool LLAgent::onIdle() +bool LLAgent::pollHttp(const LLSD&) { - if (!LLAgent::mActive) - return true; - mHttpRequest->update(0L); - return false; + mHttpRequest->update(0L); + return false; } + // Handle any actions that need to be performed when the main app gains focus // (such as through alt-tab). //----------------------------------------------------------------------------- @@ -2548,8 +2552,8 @@ int LLAgent::convertTextToMaturity(char text) class LLMaturityHttpHandler : public LLHttpSDHandler { public: - LLMaturityHttpHandler(const std::string& capabilityURL, LLAgent *agent, U8 preferred, U8 previous): - LLHttpSDHandler(capabilityURL), + LLMaturityHttpHandler(LLAgent *agent, U8 preferred, U8 previous): + LLHttpSDHandler(), mAgent(agent), mPreferredMaturity(preferred), mPreviousMaturity(previous) @@ -2764,7 +2768,7 @@ void LLAgent::sendMaturityPreferenceToServer(U8 pPreferredMaturity) return; } - LLMaturityHttpHandler * handler = new LLMaturityHttpHandler(url, this, pPreferredMaturity, mLastKnownResponseMaturity); + LLMaturityHttpHandler * handler = new LLMaturityHttpHandler(this, pPreferredMaturity, mLastKnownResponseMaturity); LLSD access_prefs = LLSD::emptyMap(); access_prefs["max"] = LLViewerRegion::accessToShortString(pPreferredMaturity); @@ -2779,14 +2783,14 @@ void LLAgent::sendMaturityPreferenceToServer(U8 pPreferredMaturity) if (handle == LLCORE_HTTP_HANDLE_INVALID) { delete handler; - LL_WARNS("Avatar") << "Maturity request post failed." << LL_ENDL; + LL_WARNS("Agent") << "Maturity request post failed." << LL_ENDL; } } } LLCore::HttpHandle LLAgent::requestPostCapability(const std::string &cap, const std::string &url, LLSD &postData, LLHttpSDHandler *usrhndlr) { - LLHttpSDHandler * handler = (usrhndlr) ? usrhndlr : new LLHttpSDGenericHandler(url, cap); + LLHttpSDHandler * handler = (usrhndlr) ? usrhndlr : new LLHttpSDGenericHandler(cap); LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, mHttpPolicy, mHttpPriority, url, postData, mHttpOptions, mHttpHeaders, handler); @@ -2799,16 +2803,31 @@ LLCore::HttpHandle LLAgent::requestPostCapability(const std::string &cap, const if (!usrhndlr) delete handler; LLCore::HttpStatus status = mHttpRequest->getStatus(); - LL_WARNS("Avatar") << "'" << cap << "' request POST failed. Reason " + LL_WARNS("Agent") << "'" << cap << "' request POST failed. Reason " << status.toTerseString() << " \"" << status.toString() << "\"" << LL_ENDL; } return handle; } -//LLCore::HttpHandle LLAgent::httpGetCapibility(const std::string &cap, const LLURI &uri, LLHttpSDHandler *usrhndlr) -//{ -//} +LLCore::HttpHandle LLAgent::requestGetCapability(const std::string &cap, const std::string &url, LLHttpSDHandler *usrhndlr) +{ + LLHttpSDHandler * handler = (usrhndlr) ? usrhndlr : new LLHttpSDGenericHandler(cap); + LLCore::HttpHandle handle = mHttpRequest->requestGet(mHttpPolicy, mHttpPriority, + url, mHttpOptions.get(), mHttpHeaders.get(), handler); + if (handle == LLCORE_HTTP_HANDLE_INVALID) + { + // If no handler was passed in we delete the handler default handler allocated + // at the start of this function. + // *TODO: Change this metaphore to use boost::shared_ptr<> for handlers. Requires change in LLCore::HTTP + if (!usrhndlr) + delete handler; + LLCore::HttpStatus status = mHttpRequest->getStatus(); + LL_WARNS("Agent") << "'" << cap << "' request GET failed. Reason " + << status.toTerseString() << " \"" << status.toString() << "\"" << LL_ENDL; + } + return handle; +} BOOL LLAgent::getAdminOverride() const { diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 26120b52f6..9ffc9b9a7a 100755 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -34,6 +34,7 @@ #include "llcoordframe.h" // for mFrameAgent #include "llavatarappearancedefines.h" #include "llpermissionsflags.h" +#include "llevents.h" #include "v3dmath.h" #include "httprequest.h" #include "httpheaders.h" @@ -117,9 +118,7 @@ public: void cleanup(); private: - bool onIdle(); - static bool mActive; //-------------------------------------------------------------------- // Login //-------------------------------------------------------------------- @@ -767,6 +766,7 @@ private: LLCore::HttpOptions::ptr_t mHttpOptions; LLCore::HttpRequest::policy_t mHttpPolicy; LLCore::HttpRequest::priority_t mHttpPriority; + LLTempBoundListener mBoundListener; bool isMaturityPreferenceSyncedWithServer() const; void sendMaturityPreferenceToServer(U8 pPreferredMaturity); @@ -781,6 +781,8 @@ private: void handleMaturity(const LLSD &pNewValue); bool validateMaturity(const LLSD& newvalue); + bool pollHttp(const LLSD &); + /** Access ** ** @@ -924,9 +926,9 @@ public: **/ public: /// Utilities for allowing the the agent sub managers to post and get via - /// HTTP using the agent's policy settings and headers. + /// HTTP using the agent's policy settings and headers. LLCore::HttpHandle requestPostCapability(const std::string &cap, const std::string &url, LLSD &postData, LLHttpSDHandler *usrhndlr = NULL); - //LLCore::HttpHandle httpGetCapability(const std::string &cap, const LLURI &uri, LLHttpSDHandler *usrhndlr = NULL); + LLCore::HttpHandle requestGetCapability(const std::string &cap, const std::string &url, LLHttpSDHandler *usrhndlr = NULL); /** Utility ** ** diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 709d9881e1..4fbcd90baa 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -1249,8 +1249,8 @@ static void removeDuplicateItems(LLInventoryModel::item_array_t& items) class LLAppearanceMgrHttpHandler : public LLHttpSDHandler { public: - LLAppearanceMgrHttpHandler(const std::string& capabilityURL, LLAppearanceMgr *mgr) : - LLHttpSDHandler(capabilityURL), + LLAppearanceMgrHttpHandler(LLAppearanceMgr *mgr) : + LLHttpSDHandler(), mManager(mgr) { } @@ -1314,7 +1314,7 @@ void LLAppearanceMgrHttpHandler::onSuccess(LLCore::HttpResponse * response, cons void LLAppearanceMgrHttpHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) { - LL_WARNS("Avatar") << "Appearance Mgr request failed to " << getUri() + LL_WARNS("Avatar") << "Appearance Mgr request failed to " << response->getRequestURL() << ". Reason code: (" << status.toTerseString() << ") " << status.toString() << LL_ENDL; } @@ -3434,7 +3434,7 @@ void LLAppearanceMgr::requestServerAppearanceUpdate() } LL_DEBUGS("Avatar") << "request url " << url << " my_cof_version " << cof_version << LL_ENDL; - LLAppearanceMgrHttpHandler * handler = new LLAppearanceMgrHttpHandler(url, this); + LLAppearanceMgrHttpHandler * handler = new LLAppearanceMgrHttpHandler(this); mInFlightCounter++; mInFlightTimer.setTimerExpirySec(60.0); diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 78fbe9af0a..8a726ec7c9 100755 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -70,7 +70,7 @@ public: typedef boost::function<void(bool, const LLSD&)> CallbackFunction; typedef boost::shared_ptr<LLMaterialHttpHandler> ptr_t; - LLMaterialHttpHandler(const std::string& method, const std::string& capabilityURL, CallbackFunction cback); + LLMaterialHttpHandler(const std::string& method, CallbackFunction cback); virtual ~LLMaterialHttpHandler(); @@ -83,8 +83,8 @@ private: CallbackFunction mCallback; }; -LLMaterialHttpHandler::LLMaterialHttpHandler(const std::string& method, const std::string& capabilityURL, CallbackFunction cback): - LLHttpSDHandler(capabilityURL), +LLMaterialHttpHandler::LLMaterialHttpHandler(const std::string& method, CallbackFunction cback): + LLHttpSDHandler(), mMethod(method), mCallback(cback) { @@ -106,7 +106,7 @@ void LLMaterialHttpHandler::onFailure(LLCore::HttpResponse * response, LLCore::H LL_WARNS("Materials") << "\n--------------------------------------------------------------------------\n" << mMethod << " Error[" << status.toULong() << "] cannot access cap '" << MATERIALS_CAPABILITY_NAME - << "'\n with url '" << getUri() << "' because " << status.toString() + << "'\n with url '" << response->getRequestURL() << "' because " << status.toString() << "\n--------------------------------------------------------------------------" << LL_ENDL; @@ -653,7 +653,7 @@ void LLMaterialMgr::processGetQueue() postData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; LLMaterialHttpHandler * handler = - new LLMaterialHttpHandler("POST", capURL, + new LLMaterialHttpHandler("POST", boost::bind(&LLMaterialMgr::onGetResponse, this, _1, _2, region_id) ); @@ -707,7 +707,7 @@ void LLMaterialMgr::processGetAllQueue() LL_DEBUGS("Materials") << "GET all for region " << region_id << "url " << capURL << LL_ENDL; LLMaterialHttpHandler *handler = - new LLMaterialHttpHandler("GET", capURL, + new LLMaterialHttpHandler("GET", boost::bind(&LLMaterialMgr::onGetAllResponse, this, _1, _2, *itRegion) ); @@ -810,7 +810,7 @@ void LLMaterialMgr::processPutQueue() LL_DEBUGS("Materials") << "put for " << itRequest->second.size() << " faces to region " << itRequest->first->getName() << LL_ENDL; LLMaterialHttpHandler * handler = - new LLMaterialHttpHandler("PUT", capURL, + new LLMaterialHttpHandler("PUT", boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2) ); |